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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]