Re: git-cherry-pick and git-commit --amend in version 1.7.6.4

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

Re: git-cherry-pick and git-commit --amend in version 1.7.6.4

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:52:11

Jay Soffian [off-list ref] writes:
On Wed, Oct 5, 2011 at 1:40 PM, Junio C Hamano [off-list ref] wrote:
quoted
Pinging Jay who may have know a thing or two from the history leading to
37f7a85 (Teach commit about CHERRY_PICK_HEAD, 2011-02-19).
Yep, I replied to Nicolas' other message.

j.
This is probably different fro Nicolas's use case, but you can easily
trigger:

 $ edit foo.c
 $ EDITOR=: git commit --amend ;# forget to add foo.c
 $ git cherry-pick other
 error: Your local changes to the following files would be overwritten by
 merge:
        foo.c
 Please, commit your changes or stash them before you can merge.
 Aborting
 $ EDITOR=: git commit --amend foo.c
 fatal: You are in the middle of a cherry-pick -- cannot amend.

I think the sequencer state needs to be removed when the command aborts.

This needs to be fixed before 1.7.7.1.

Re: git-cherry-pick and git-commit --amend in version 1.7.6.4

From: Jay Soffian <hidden>
Date: 2016-06-15 22:52:11

On Wed, Oct 5, 2011 at 5:55 PM, Junio C Hamano [off-list ref] wrote:
I think the sequencer state needs to be removed when the command aborts.
Or written later in do_pick_commit().
This needs to be fixed before 1.7.7.1.
Something like this?
diff --git i/builtin/revert.c w/builtin/revert.c
index 3117776c2c..f7fcc88871 100644
--- i/builtin/revert.c
+++ w/builtin/revert.c
@@ -384,6 +384,7 @@ static int do_pick_commit(void)
 	char *defmsg = NULL;
 	struct strbuf msgbuf = STRBUF_INIT;
 	int res;
+	int record_cherry_pick_head = 0;

 	if (no_commit) {
 		/*
@@ -477,7 +478,7 @@ static int do_pick_commit(void)
 			strbuf_addstr(&msgbuf, ")\n");
 		}
 		if (!no_commit)
-			write_cherry_pick_head();
+			record_cherry_pick_head = 1;
 	}

 	if (!strategy || !strcmp(strategy, "recursive") || action == REVERT) {
@@ -514,6 +515,9 @@ static int do_pick_commit(void)
 	free_message(&msg);
 	free(defmsg);

+	if (record_cherry_pick_head)
+		write_cherry_pick_head();
+
 	return res;
 }
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help