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, 01:09 UTC
Message-ID
<7vpsi4xm7q.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<7vd5e4z2je.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano <junkio@cox.net> writes:
Show 20 quoted lines
> To git-apply, this patch:
>
>         diff --git a/file b/file
>         --- a/file
>         +++ b/file
>         @@ -1,2 +1,3 @@
>          a
>          b
>         +c
>
> currently means "I want to append a line c immediately after the
> lines that have a and then b".
>...
> I do not think this is necessarily a bug.  You _could_ make the
> EOF a special case (i.e. you _could_ interpret the patch that it
> also says, with "@@ -1,2", that "the result of this patch _must_
> end with this line I just added"), and if you are going to do
> that, you would also need a symmetric special case for the
> beginning of the file, but I do not think it is the right thing
> to do in general.

Come to think of it, the above argument is bogus. We _would_ want to make EOF just like any other context lines.

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.

Previous: Junio C HamanoNext: Junio C Hamano
Message 3 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.