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

Re: [RFH] "diff -B -M"

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 6, 2015, 22:47 UTC
Message-ID
<xmqqegq2d5dv.fsf@gitster.dls.corp.google.com>
In-Reply-To
<xmqqvbjed76s.fsf@gitster.dls.corp.google.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 10 quoted lines
> 5. Third twist: rewriting by copying
> ...
> One possible way to fix this is to include another patch in the same
> patchset that shows the deletion of major-11.txt.  The rule 2. would
> be further revised to something like:
>
>  rule 2. a patch renaming file A to file B requires that file A
>          exists and file B does not exist in the target tree, unless
>          another patch in the patchset renames file B to some other
>          file (possibly but not necessarily file A) or removed file
Typofix: s/removed/removes/
Show 30 quoted lines
>          B, in which case file B must appear in the target tree.
>
> Such a patchset would look like this:
>
>     diff --git a/major-08.txt b/major-11.txt
>     similarity index 97%
>     rename from major-08.txt
>     rename to major-11.txt
> ...
>     diff --git a/major-11.txt b/major-11.txt
>     deleted file mode 100644
> ...
>
> And these patches, under the re-revised rule 2. and rule 4., would
> apply cleanly to the old tree.
>
> What about the reverse application?  It would be a patchset that
> creates major-11.txt from nothingness, and creates major-08.txt by
> renaming major-11.txt and editing.  Is the rule 2. re-revised above
> sufficient?
>
>     renaming major-11.txt to major-08.txt requires that major-08.txt
>     does not exist in the target tree, unless...
>
> and the new tree (which is the target of the reverse application)
> only has major-11.txt and not major-08.txt, so this rename should go
> through.  The reverse of the deletion of major-11.txt is a creation
> of it with the contents fully given as the pre-image of the
> (original) patch before reversing it, so that should also be OK with
> rule 3.

... But rule 3. needs tweaking. The second patch would be creating major-11.txt which requires major-11.txt to be missing in the target tree. But obviously, the new tree the patch we are applying in reverse was taken from has major-11.txt. So we would need a revision to it as well.

 rule 3. a patch that creates file A requires that file A does not exist
         in the target tree, unless another patch in the same patchset
         renames file A away or removes it.
Show 8 quoted lines
> So tentatively, I would say...
>
> 	Action item: do not filter delete-half of the broken pair
> 	out, even when the other create-half of the pair no longer
> 	is in the output.
>
> 	Action item: update "git apply" to honor the rule 2.
> 	re-revised above.
The latter should read:
	update "git apply" to honor the revised rule 2. and 3.
Previous: Junio C HamanoNext: Junio C Hamano
Message 2 of 4 in “[RFH] "diff -B -M"”
  1. Junio C HamanoFeb 6, 2015
  2. Junio C HamanoFeb 6, 2015
  3. apply: do not allow reversing a 'copy' patchJunio C Hamano, Feb 6, 2015
  4. Stefan BellerFeb 6, 2015

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.