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

From: Junio C Hamano <[email-masked]>
Date: Fri, 06 Feb 2015 15:06:01 -0800

Junio C Hamano <[email-masked]> 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);