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

git-apply quirks

From
DZDon Zickus <dzickus@redhat.com>
Date
Jun 10, 2008, 19:40 UTC
Message-ID
<20080610194000.GD9304@redhat.com>
Hi.

I work with a lot of backporting of patches and there are times when people combine multiple patches together such that the resulting patch can have multiple chunks changing the same file. I have noticed git-apply does not handle this case correctly. It usually ignores all previous chunks and only applies the last one.

The same scenario can also cause git-apply to fail if a later patch chunk depends on changes from an earlier patch chunk.

The traditional 'patch' command seems to handle the successfully. Is this git-apply behaviour intended or is it a bug?

The following example summarizes the problem:

#cd <some git repo> # cat > dummy << EOF This is a test of git-apply doing something incorrectly.

Please help.

EOF #git-add dummy #git commit -m 'test' #git-apply <attached patch below>

You will notice in the git-diff output the first chunk is ignored and only the second applies.

Cheers, Don

diff a/dummy b/dummy
--- a/dummy
+++ b/dummy
@@ -1,5 +1,5 @@
 This is
-a
+the first
 test
 of
 git-apply

diff a/dummy b/dummy
--- a/dummy
+++ b/dummy
@@ -6,6 +6,8 @@ git-apply
 doing
 something
 incorrectly.
+Now here is the
+second test.
 
 Please
 help.
Message 1 of 1 in “git-apply quirks”
  1. Don ZickusJun 10, 2008

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.