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

[PATCH] apply: do not allow reversing a 'copy' patch

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 6, 2015, 23:06 UTC
Message-ID
<xmqqa90qd4iu.fsf@gitster.dls.corp.google.com>
In-Reply-To
<xmqqvbjed76s.fsf@gitster.dls.corp.google.com>
Junio C Hamano <gitster@pobox.com> writes:
>         Action item: warn users against using "apply -R" on a
>         patchset with such a patch while this is fixed.

This needs to be replaced with the logic to properly reverse a patch that creates a new file by copying from somewhere else, but for now, this would be a good idea to prevent lossages from happening.

 builtin/apply.c | 3 +++
 1 file changed, 3 insertions(+)
diff --git a/builtin/apply.c b/builtin/apply.c
index 0aad912..b33b403 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -2069,6 +2069,9 @@ static void reverse_patches(struct patch *p)
 	for (; p; p = p->next) {
 		struct fragment *frag = p->fragments;
 
+		if (p->is_copy)
+			die(_("sorry, cannot apply a 'copying' patch in reverse (yet)"));
+
 		swap(p->new_name, p->old_name);
 		swap(p->new_mode, p->old_mode);
 		swap(p->is_new, p->is_delete);
Previous: Junio C HamanoNext: Stefan Beller
Message 3 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.