List Info

Thread: 23.0.60; diff-apply-hunk new line at end of file




23.0.60; diff-apply-hunk new line at end of file
user name
2008-04-24 18:23:39
Re: 23.0.60; diff-apply-hunk new line at end of file
user name
2008-04-24 18:42:58
Markus Triska <markus.triskagmx.at> writes:
> and do C-c C-a on the first and only hunk of t.patch,
the patch is
> applied. When I then do C-c C-a, another new line is
unexpectedly
> inserted at the end of t.txt. Arbitrarily many, if
repeated.

That's because there isn't enough context in the hunk.  It's
a general
problem with the patch format.

-Miles

-- 
"I distrust a research person who is always obviously
busy on a task."
   --Robert Frosch, VP, GM Research



Re: 23.0.60; diff-apply-hunk new line at end of file
user name
2008-04-24 19:22:16
Miles Bader <milesgnu.org> writes:

> That's because there isn't enough context in the hunk.

A good guess from the hunk is that the context was at least
1 line, thus
it could be seen that the new line must be the last one in
the file, no?



Re: 23.0.60; diff-apply-hunk new line at end of file
user name
2008-04-24 19:38:46
>> That's because there isn't enough context in the
hunk.

I now see what you mean - you're right, this cannot be
fixed. Thanks!



Re: 23.0.60; diff-apply-hunk new line at end of file
user name
2008-04-24 20:37:46
> diff --git a/t.txt b/t.txt
> index f27f040..27bd94f 100644
> --- a/t.txt
> +++ b/t.txt
>  -1 +1,2 
>  first line.
> +

> (available from: http://www.logic.a
t/prolog/t.patch )

> and, in the same directory, t.txt with the following
content:

> first line.

> (available from: http://www.logic.at/
prolog/t.txt )

> and do C-c C-a on the first and only hunk of t.patch,
the patch is
> applied. When I then do C-c C-a, another new line is
unexpectedly
> inserted at the end of t.txt. Arbitrarily many, if
repeated.

Why would that be a bug?  The patch doesn't say that it is
at the end of
the file, so all it says is "add an empty line after
the line `first
line'".  You may argue that the lack of context is an
indication that
it's meant to be at the end-of-file, but that lack of
context may be due
to something else.

Furthermore, the same kind of problem can happen even with
3-lines of
context, such that after applying the patch, the new file's
content
still contains the pattern required for the patch be
applied.


        Stefan



[1-5]

about | contact  Other archives ( Real Estate discussion Medical topics )