Skip to content

Commit

Permalink
status: show commit sha1 in "You are currently cherry-picking" message
Browse files Browse the repository at this point in the history
Especially helpful when cherry-picking multiple commits.

Signed-off-by: Ralf Thielow <ralf.thielow@gmail.com>
Acked-by: Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
  • Loading branch information
ralfth authored and jrn committed Oct 11, 2013
1 parent 59c2220 commit bffd809
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
10 changes: 6 additions & 4 deletions t/t7512-status-help.sh
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
7 changes: 5 additions & 2 deletions wt-status.c
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions wt-status.h
Expand Up @@ -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);
Expand Down

0 comments on commit bffd809

Please sign in to comment.