Skip to content

Commit 0e3b378

Browse files
committed
Merge branch 'rt/cherry-pick-status'
* rt/cherry-pick-status: status: show commit sha1 in "You are currently cherry-picking" message status test: add missing && to <<EOF blocks
2 parents 865156a + bffd809 commit 0e3b378

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

t/t7512-status-help.sh

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -626,9 +626,10 @@ test_expect_success 'prepare for cherry-pick conflicts' '
626626
test_expect_success 'status when cherry-picking before resolving conflicts' '
627627
test_when_finished "git cherry-pick --abort" &&
628628
test_must_fail git cherry-pick cherry_branch_second &&
629-
cat >expected <<\EOF &&
629+
TO_CHERRY_PICK=$(git rev-parse --short CHERRY_PICK_HEAD) &&
630+
cat >expected <<EOF &&
630631
On branch cherry_branch
631-
You are currently cherry-picking.
632+
You are currently cherry-picking commit $TO_CHERRY_PICK.
632633
(fix conflicts and run "git cherry-pick --continue")
633634
(use "git cherry-pick --abort" to cancel the cherry-pick operation)
634635
@@ -648,11 +649,12 @@ test_expect_success 'status when cherry-picking after resolving conflicts' '
648649
git reset --hard cherry_branch &&
649650
test_when_finished "git cherry-pick --abort" &&
650651
test_must_fail git cherry-pick cherry_branch_second &&
652+
TO_CHERRY_PICK=$(git rev-parse --short CHERRY_PICK_HEAD) &&
651653
echo end >main.txt &&
652654
git add main.txt &&
653-
cat >expected <<\EOF &&
655+
cat >expected <<EOF &&
654656
On branch cherry_branch
655-
You are currently cherry-picking.
657+
You are currently cherry-picking commit $TO_CHERRY_PICK.
656658
(all conflicts fixed: run "git cherry-pick --continue")
657659
(use "git cherry-pick --abort" to cancel the cherry-pick operation)
658660
@@ -669,15 +671,15 @@ EOF
669671
test_expect_success 'status showing detached at and from a tag' '
670672
test_commit atag tagging &&
671673
git checkout atag &&
672-
cat >expected <<\EOF
674+
cat >expected <<\EOF &&
673675
HEAD detached at atag
674676
nothing to commit (use -u to show untracked files)
675677
EOF
676678
git status --untracked-files=no >actual &&
677679
test_i18ncmp expected actual &&
678680
679681
git reset --hard HEAD^ &&
680-
cat >expected <<\EOF
682+
cat >expected <<\EOF &&
681683
HEAD detached from atag
682684
nothing to commit (use -u to show untracked files)
683685
EOF
@@ -695,7 +697,7 @@ test_expect_success 'status while reverting commit (conflicts)' '
695697
test_commit new to-revert.txt &&
696698
TO_REVERT=$(git rev-parse --short HEAD^) &&
697699
test_must_fail git revert $TO_REVERT &&
698-
cat >expected <<EOF
700+
cat >expected <<EOF &&
699701
On branch master
700702
You are currently reverting commit $TO_REVERT.
701703
(fix conflicts and run "git revert --continue")
@@ -716,7 +718,7 @@ EOF
716718
test_expect_success 'status while reverting commit (conflicts resolved)' '
717719
echo reverted >to-revert.txt &&
718720
git add to-revert.txt &&
719-
cat >expected <<EOF
721+
cat >expected <<EOF &&
720722
On branch master
721723
You are currently reverting commit $TO_REVERT.
722724
(all conflicts fixed: run "git revert --continue")
@@ -735,7 +737,7 @@ EOF
735737

736738
test_expect_success 'status after reverting commit' '
737739
git revert --continue &&
738-
cat >expected <<\EOF
740+
cat >expected <<\EOF &&
739741
On branch master
740742
nothing to commit (use -u to show untracked files)
741743
EOF

wt-status.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -996,7 +996,8 @@ static void show_cherry_pick_in_progress(struct wt_status *s,
996996
struct wt_status_state *state,
997997
const char *color)
998998
{
999-
status_printf_ln(s, color, _("You are currently cherry-picking."));
999+
status_printf_ln(s, color, _("You are currently cherry-picking commit %s."),
1000+
find_unique_abbrev(state->cherry_pick_head_sha1, DEFAULT_ABBREV));
10001001
if (s->hints) {
10011002
if (has_unmerged(s))
10021003
status_printf_ln(s, color,
@@ -1169,8 +1170,10 @@ void wt_status_get_state(struct wt_status_state *state,
11691170
state->rebase_in_progress = 1;
11701171
state->branch = read_and_strip_branch("rebase-merge/head-name");
11711172
state->onto = read_and_strip_branch("rebase-merge/onto");
1172-
} else if (!stat(git_path("CHERRY_PICK_HEAD"), &st)) {
1173+
} else if (!stat(git_path("CHERRY_PICK_HEAD"), &st) &&
1174+
!get_sha1("CHERRY_PICK_HEAD", sha1)) {
11731175
state->cherry_pick_in_progress = 1;
1176+
hashcpy(state->cherry_pick_head_sha1, sha1);
11741177
}
11751178
if (!stat(git_path("BISECT_LOG"), &st)) {
11761179
state->bisect_in_progress = 1;

wt-status.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ struct wt_status_state {
8888
char *detached_from;
8989
unsigned char detached_sha1[20];
9090
unsigned char revert_head_sha1[20];
91+
unsigned char cherry_pick_head_sha1[20];
9192
};
9293

9394
void wt_status_prepare(struct wt_status *s);

0 commit comments

Comments
 (0)