Re: [PATCH] Add a test-case for git-apply trying to add an ending line
- From
Linus Torvalds <torvalds@osdl.org>
- Date
- May 24, 2006, 14:49 UTC
- Message-ID
- <Pine.LNX.4.64.0605240745590.5623@g5.osdl.org>
- In-Reply-To
- <7v8xosqaqm.fsf@assigned-by-dhcp.cox.net>
On Tue, 23 May 2006, Junio C Hamano wrote:
Show 16 quoted lines
> Linus Torvalds <torvalds@osdl.org> writes: > > > On Tue, 23 May 2006, Junio C Hamano wrote: > > > >> The issue is if we can reliably tell if there is such an EOF > >> context by looking at the diff. Not having the same number of > >> lines that starts with ' ' in the hunk is not really a nice way > >> of doing so (you could make a unified diff that does not have > >> trailing context at all), and I do not offhand think of a good > >> way to do so. > > > > We can. Something like this should do it. > > > > (The same thing could be done for "match_beginning", perhaps). > > But this is exactly what I said I had trouble with in the above.
Well, not quite. You said "not the same number of lines", and I say "no ending context". Very different.
My patch actually is totally self-consistent: not having any context at the end of a unified diff really means that it is the end of the file (ie, the "end of file" there _is_ the context). And if you want to apply files without context, you should use "-Cx", and my patch does that too - if you asked for "relaxed context checking", it will re-try without the "only at end" check thanks to the
if (match_end) {
match_end = 0;
continue;
}so it all should work.
Not that I _tested_ it, of course ;)
Linus