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

[PATCH] rebase -i: remove CHERRY_PICK_HEAD when cherry-pick failed

From
Andrew Wong <andrew.kw.w@gmail.com>
Date
Mar 18, 2012, 21:37 UTC
Message-ID
<1332106632-31882-1-git-send-email-andrew.kw.w@gmail.com>
In-Reply-To
<CAMP44s1EAwHjQ7S2ArLvhNg5qkR05DRJ70tQmP8sXYdOP=i_zQ@mail.gmail.com>

Instead of having the sequencer catch errors and remove CHERRY_PICK_HEAD for its caller's sake, let its caller do the work. This way, the sequencer doesn't have to check all points of failures where its caller doesn't want CHERRY_PICK_HEAD.

For example, the sequencer current doesn't clean up CHERRY_PICK_HEAD if 'commit' failed due to an empty commit. Letting 'rebase -i' deal with removing CHERRY_PICK_HEAD keeps the sequencer's logic a bit cleaner.

Signed-off-by: Andrew Wong <andrew.kw.w@gmail.com>
---
 git-rebase--interactive.sh |   10 +++++++++-
 sequencer.c                |    6 ------
 2 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 5812222..061248c 100644
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -196,7 +196,12 @@ pick_one () {
 	output git rev-parse --verify $sha1 || die "Invalid commit name: $sha1"
 	test -d "$rewritten" &&
 		pick_one_preserving_merges "$@" && return
-	output git cherry-pick $ff "$@"
+	output git cherry-pick $ff "$@" ||
+	{
+		status=$?
+		rm -f "$GIT_DIR"/CHERRY_PICK_HEAD
+		return $status
+	}
 }
 
 pick_one_preserving_merges () {
@@ -308,7 +313,10 @@ pick_one_preserving_merges () {
 			;;
 		*)
 			output git cherry-pick "$@" ||
+			{
+				rm -f "$GIT_DIR"/CHERRY_PICK_HEAD
 				die_with_patch $sha1 "Could not pick $sha1"
+			}
 			;;
 		esac
 		;;
diff --git a/sequencer.c b/sequencer.c
index a37846a..c2eceb5 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -129,12 +129,6 @@ static void print_advice(int show_hint, struct replay_opts *opts)
 
 	if (msg) {
 		fprintf(stderr, "%s\n", msg);
-		/*
-		 * A conflict has occured but the porcelain
-		 * (typically rebase --interactive) wants to take care
-		 * of the commit itself so remove CHERRY_PICK_HEAD
-		 */
-		unlink(git_path("CHERRY_PICK_HEAD"));
 		return;
 	}
 
-- 
1.7.10.rc1.22.gf5241
Previous: Felipe ContrerasNext: Junio C Hamano
Message 4 of 22 in “Rebase regression in v1.7.9?”
  1. Felipe ContrerasJan 31, 2012
  2. Andrew WongFeb 1, 2012
  3. Felipe ContrerasFeb 1, 2012
  4. rebase -i: remove CHERRY_PICK_HEAD when cherry-pick failedAndrew Wong, Mar 18, 2012
  5. Junio C HamanoMar 19, 2012
  6. Andrew WongMar 19, 2012
  7. Andrew WongMar 24, 2012
  8. Andrew WongApr 2, 2012
  9. Junio C HamanoApr 2, 2012
  10. Junio C HamanoApr 3, 2012
  11. Ramkumar RamachandraApr 3, 2012
  12. Jonathan NiederApr 3, 2012
  13. Andrew WongApr 3, 2012
  14. Jonathan NiederApr 3, 2012
  15. Jonathan NiederApr 3, 2012
  16. Andrew WongApr 3, 2012
  17. Jonathan NiederApr 3, 2012
  18. Andrew WongApr 3, 2012
  19. Jonathan NiederApr 4, 2012
  20. Andrew WongApr 4, 2012
  21. Jonathan NiederApr 4, 2012
  22. Jonathan NiederApr 4, 2012

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.