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
CMCatalin Marinas <catalin.marinas@gmail.com>
Date
May 24, 2006, 13:32 UTC
Message-ID
<b0943d9e0605240632t4189f8d0yfdbab111c83f0426@mail.gmail.com>
In-Reply-To
<7v8xosqaqm.fsf@assigned-by-dhcp.cox.net>
On 24/05/06, Junio C Hamano <junkio@cox.net> wrote:
Show 5 quoted lines
> 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...

The reason I sent you this test is that GNU patch fails to apply the diff but git-apply succeeds (and I thought git-apply is more restrictive).

When there are context lines either before or after the "+" line, it should be OK to assume that the diff has context and therefore the EOF should be considered.

If there are no context lines at all, the diff is either without context or it is meant to patch an empty file. The latter is safer and probably valid for most of the cases but if you have a patch without context, you could explicitely pass the -C0 option to git-apply.

-- 
Catalin
Previous: Junio C HamanoNext: Linus Torvalds
Message 8 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.