From: Junio C Hamano Date: Wed, 24 May 2006 04:59:13 GMT Subject: Re: [PATCH] Add a test-case for git-apply trying to add an ending line Message-ID: <7v8xosqaqm.fsf@assigned-by-dhcp.cox.net> In-Reply-To: Linus Torvalds 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. In the extreme case, wouldn't this make git apply to refuse to apply a self generated patch with 0-line context? IOW, $ git checkout -- foo ;# reset to indexed version $ edit foo $ git diff -U0 >P.diff $ git checkout -- foo ;# reset to indexed version $ git apply