git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Add a test-case for git-apply trying to add an ending line

From
Junio C Hamano <junkio@cox.net>
Date
May 24, 2006, 04:59 UTC
Message-ID
<7v8xosqaqm.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<Pine.LNX.4.64.0605231905470.5623@g5.osdl.org>
Linus Torvalds <torvalds@osdl.org> writes:
Show 12 quoted lines
> 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 <P.diff
would fail, even though it _should_ cleanly apply.

I'd admit that trying to apply a patch without context like the above example _is_ insane, and I realize that I am making this problem unsolvable by refusing the heuristics to consider that the patch is anchored at the end when we do not see any trailing context. But somehow it feels wrong...

Previous: Linus TorvaldsNext: Catalin Marinas
Message 7 of 9 in “Add a test-case for git-apply trying to add an ending line”
  1. Add a test-case for git-apply trying to add an ending lineCatalin Marinas, May 23, 2006
  2. Junio C HamanoMay 24, 2006
  3. Junio C HamanoMay 24, 2006
  4. Junio C HamanoMay 24, 2006
  5. Linus TorvaldsMay 24, 2006
  6. Linus TorvaldsMay 24, 2006
  7. Junio C HamanoMay 24, 2006
  8. Catalin MarinasMay 24, 2006
  9. Linus TorvaldsMay 24, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.