git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Andrew Wong <andrew.kw.w@gmail.com>
To: git@vger.kernel.org
Cc: Andrew Wong <andrew.kw.w@gmail.com>
Subject: [PATCH] rebase -i: remove CHERRY_PICK_HEAD when cherry-pick failed
Date: Sun, 18 Mar 2012 17:37:12 -0400	[thread overview]
Message-ID: <1332106632-31882-1-git-send-email-andrew.kw.w@gmail.com> (raw)
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

  parent reply	other threads:[~2012-03-18 22:39 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-31 22:56 Rebase regression in v1.7.9? Felipe Contreras
2012-02-01 17:27 ` Andrew Wong
2012-02-01 19:30   ` Felipe Contreras
2012-03-18 21:37 ` Andrew Wong [this message]
2012-03-19 16:51   ` [PATCH] rebase -i: remove CHERRY_PICK_HEAD when cherry-pick failed Junio C Hamano
2012-03-19 21:00     ` Andrew Wong
2012-03-24 20:03       ` Andrew Wong
2012-04-02 22:38         ` Andrew Wong
2012-04-02 23:08           ` Junio C Hamano
2012-04-03  5:15             ` Junio C Hamano
2012-04-03  6:32   ` Ramkumar Ramachandra
2012-04-03 14:45     ` Jonathan Nieder
2012-04-03 21:01       ` Andrew Wong
2012-04-03 21:08         ` Jonathan Nieder
2012-04-03 21:12           ` Jonathan Nieder
2012-04-03 21:22             ` Andrew Wong
2012-04-03 21:26               ` Jonathan Nieder
2012-04-03 23:11                 ` Andrew Wong
2012-04-04 18:11                   ` Jonathan Nieder
2012-04-04 19:23                     ` Andrew Wong
2012-04-04 20:16                       ` Jonathan Nieder
2012-04-04 20:20                         ` Jonathan Nieder

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1332106632-31882-1-git-send-email-andrew.kw.w@gmail.com \
    --to=andrew.kw.w@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).