git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Ralf Thielow <ralf.thielow@gmail.com>
To: git@vger.kernel.org
Cc: gitster@pobox.com, jrnieder@gmail.com, Matthieu.Moy@imag.fr,
	Ralf Thielow <ralf.thielow@gmail.com>
Subject: [PATCH] status: show commit sha1 in "You are currently cherry-picking" message
Date: Fri, 11 Oct 2013 17:58:37 +0200	[thread overview]
Message-ID: <1381507117-11519-1-git-send-email-ralf.thielow@gmail.com> (raw)

Signed-off-by: Ralf Thielow <ralf.thielow@gmail.com>
---

Especially helpful when cherry-picking multiple commits.

 t/t7512-status-help.sh | 10 ++++++----
 wt-status.c            |  7 +++++--
 wt-status.h            |  1 +
 3 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/t/t7512-status-help.sh b/t/t7512-status-help.sh
index 0688d58..0a65db1 100755
--- a/t/t7512-status-help.sh
+++ b/t/t7512-status-help.sh
@@ -626,9 +626,10 @@ test_expect_success 'prepare for cherry-pick conflicts' '
 test_expect_success 'status when cherry-picking before resolving conflicts' '
 	test_when_finished "git cherry-pick --abort" &&
 	test_must_fail git cherry-pick cherry_branch_second &&
-	cat >expected <<\EOF &&
+	TO_CHERRY_PICK=$(git rev-parse --short CHERRY_PICK_HEAD) &&
+	cat >expected <<EOF
 On branch cherry_branch
-You are currently cherry-picking.
+You are currently cherry-picking commit $TO_CHERRY_PICK.
   (fix conflicts and run "git cherry-pick --continue")
   (use "git cherry-pick --abort" to cancel the cherry-pick operation)
 
@@ -648,11 +649,12 @@ test_expect_success 'status when cherry-picking after resolving conflicts' '
 	git reset --hard cherry_branch &&
 	test_when_finished "git cherry-pick --abort" &&
 	test_must_fail git cherry-pick cherry_branch_second &&
+	TO_CHERRY_PICK=$(git rev-parse --short CHERRY_PICK_HEAD) &&
 	echo end >main.txt &&
 	git add main.txt &&
-	cat >expected <<\EOF &&
+	cat >expected <<EOF
 On branch cherry_branch
-You are currently cherry-picking.
+You are currently cherry-picking commit $TO_CHERRY_PICK.
   (all conflicts fixed: run "git cherry-pick --continue")
   (use "git cherry-pick --abort" to cancel the cherry-pick operation)
 
diff --git a/wt-status.c b/wt-status.c
index cbdce72..b4e44ba 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -996,7 +996,8 @@ static void show_cherry_pick_in_progress(struct wt_status *s,
 					struct wt_status_state *state,
 					const char *color)
 {
-	status_printf_ln(s, color, _("You are currently cherry-picking."));
+	status_printf_ln(s, color, _("You are currently cherry-picking commit %s."),
+			find_unique_abbrev(state->cherry_pick_head_sha1, DEFAULT_ABBREV));
 	if (s->hints) {
 		if (has_unmerged(s))
 			status_printf_ln(s, color,
@@ -1169,8 +1170,10 @@ void wt_status_get_state(struct wt_status_state *state,
 			state->rebase_in_progress = 1;
 		state->branch = read_and_strip_branch("rebase-merge/head-name");
 		state->onto = read_and_strip_branch("rebase-merge/onto");
-	} else if (!stat(git_path("CHERRY_PICK_HEAD"), &st)) {
+	} else if (!stat(git_path("CHERRY_PICK_HEAD"), &st) &&
+			!get_sha1("CHERRY_PICK_HEAD", sha1)) {
 		state->cherry_pick_in_progress = 1;
+		hashcpy(state->cherry_pick_head_sha1, sha1);
 	}
 	if (!stat(git_path("BISECT_LOG"), &st)) {
 		state->bisect_in_progress = 1;
diff --git a/wt-status.h b/wt-status.h
index 9341c56..6c29e6f 100644
--- a/wt-status.h
+++ b/wt-status.h
@@ -88,6 +88,7 @@ struct wt_status_state {
 	char *detached_from;
 	unsigned char detached_sha1[20];
 	unsigned char revert_head_sha1[20];
+	unsigned char cherry_pick_head_sha1[20];
 };
 
 void wt_status_prepare(struct wt_status *s);
-- 
1.8.4.652.g0d6e0ce

             reply	other threads:[~2013-10-11 15:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-11 15:58 Ralf Thielow [this message]
2013-10-11 16:03 ` [PATCH] status: show commit sha1 in "You are currently cherry-picking" message Matthieu Moy
2013-10-11 17:42 ` Jonathan Nieder
2013-10-11 18:14   ` Ralf Thielow
2013-10-15 13:35   ` on broken command chains in tests (was: Re: [PATCH] status: show commit sha1 in "You are currently) SZEDER Gábor

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=1381507117-11519-1-git-send-email-ralf.thielow@gmail.com \
    --to=ralf.thielow@gmail.com \
    --cc=Matthieu.Moy@imag.fr \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jrnieder@gmail.com \
    /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).