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

Re: [PATCH 2/3] Fix the processing of multiple patch files with --check in git-apply.

From
Junio C Hamano <junkio@cox.net>
Date
Sep 7, 2005, 00:54 UTC
Message-ID
<7vslwhbsu9.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<20050905123445.GA27107@localhost>
Robert Fitzsimons <robfitz@273k.net> writes:
> No problem I know it's a controversial change.

Not really controversial anymore, as long as --ignore-applied is used only when appropriate.

>>> Yes my change has a bug with a copy patch which modifies the same file.
> I'll send on a fix now.
Here is another one that the patch seems to regress.

Unfortunately this turns out to be a death sentence to the 'multiple patch touching the same file' patch.

Note that patches from a single 'git-diff-*' run are supposed to be independent, so the second one that copy-edits from frotz to rezrov copies frotz _before_ it is modified and then makes its modification.

On the other hand, we can have one 'git-diff-*' run that modifies frotz in place, and then a separate 'git-diff-*' run that copies frotz to rezrov and then modifies rezrov, and feed the concatenation of the two to git-apply. That would look very similar to a single run that edits frotz and copy-edits rezrov, but the pre-image to create rezrov would use the post-edit image of frotz from the first patch. Without an explicit "here an output from the next git-diff-*' run begins" marker, we cannot tell these two apart.

This means that applying multiple-patches concatenated in a single file does not make much sense. There is no guarantee that we can detect where the first 'git-diff-*' output ends, at which point we need to reset the status of 'frotz' to post-modification image of the first patch. And if we can detect reliably where one 'git-diff-*' output ends and the next one begins, we could just split the input there and run git-apply independently. So my conclusion is to just drop this patch, and instead tell people not to feed overlapping outputs from multiple git-diff-* runs to a single invocation of git-apply.

I personally do not mind considering --ignore-applied independently from the multiple-patch-files changes, though.

------------ echo frotz >frotz git-apply --check <<\EOF

diff --git a/frotz b/frotz
--- a/frotz
+++ b/frotz
@@ -1 +1 @@
-frotz
+frottz
diff --git a/frotz b/rezrov
similarity index 64%
copy from frotz
copy to rezrov
--- a/frotz
+++ b/rezrov
@@ -1 +1 @@
-frotz
+frotttz
EOF
Previous: Robert Fitzsmons
Message 4 of 4 in “Fix the processing of a patch file which modifies the same file in git-apply.”
  1. 1/3 Fix the processing of a patch file which modifies the same file in git-apply.Robert Fitzsmons, Aug 30, 2005
  2. 2/3 Fix the processing of multiple patch files with --check in git-apply.Robert Fitzsmons, Aug 30, 2005
  3. 3/3 New option --ignore-applied for git-apply.Robert Fitzsmons, Aug 30, 2005
  4. Junio C HamanoSep 7, 2005

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.