Skip to content

Commit 87e139c

Browse files
moygitster
authored andcommitted
status: show commit sha1 in "You are currently reverting" message
Signed-off-by: Matthieu Moy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent db4ef44 commit 87e139c

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

t/t7512-status-help.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -686,10 +686,11 @@ test_expect_success 'status while reverting commit (conflicts)' '
686686
test_commit old to-revert.txt &&
687687
echo new >to-revert.txt &&
688688
test_commit new to-revert.txt &&
689-
test_must_fail git revert HEAD^ &&
689+
TO_REVERT=$(git rev-parse --short HEAD^) &&
690+
test_must_fail git revert $TO_REVERT &&
690691
cat >expected <<-EOF
691692
# On branch master
692-
# You are currently reverting a commit.
693+
# You are currently reverting commit $TO_REVERT.
693694
# (fix conflicts and run "git revert --continue")
694695
# (use "git revert --abort" to cancel the revert operation)
695696
#
@@ -710,7 +711,7 @@ test_expect_success 'status while reverting commit (conflicts resolved)' '
710711
git add to-revert.txt &&
711712
cat >expected <<-EOF
712713
# On branch master
713-
# You are currently reverting a commit.
714+
# You are currently reverting commit $TO_REVERT.
714715
# (all conflicts fixed: run "git revert --continue")
715716
# (use "git revert --abort" to cancel the revert operation)
716717
#

wt-status.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -969,7 +969,8 @@ static void show_revert_in_progress(struct wt_status *s,
969969
struct wt_status_state *state,
970970
const char *color)
971971
{
972-
status_printf_ln(s, color, _("You are currently reverting a commit."));
972+
status_printf_ln(s, color, _("You are currently reverting commit %s."),
973+
find_unique_abbrev(state->revert_head_sha1, DEFAULT_ABBREV));
973974
if (advice_status_hints) {
974975
if (has_unmerged(s))
975976
status_printf_ln(s, color,
@@ -1104,6 +1105,7 @@ void wt_status_get_state(struct wt_status_state *state,
11041105
int get_detached_from)
11051106
{
11061107
struct stat st;
1108+
unsigned char sha1[20];
11071109

11081110
if (!stat(git_path("MERGE_HEAD"), &st)) {
11091111
state->merge_in_progress = 1;
@@ -1131,8 +1133,10 @@ void wt_status_get_state(struct wt_status_state *state,
11311133
state->bisect_in_progress = 1;
11321134
state->branch = read_and_strip_branch("BISECT_START");
11331135
}
1134-
if (!stat(git_path("REVERT_HEAD"), &st)) {
1136+
if (!stat(git_path("REVERT_HEAD"), &st) &&
1137+
!get_sha1("REVERT_HEAD", sha1)) {
11351138
state->revert_in_progress = 1;
1139+
hashcpy(state->revert_head_sha1, sha1);
11361140
}
11371141

11381142
if (get_detached_from)

wt-status.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ struct wt_status_state {
8585
char *onto;
8686
char *detached_from;
8787
unsigned char detached_sha1[20];
88+
unsigned char revert_head_sha1[20];
8889
};
8990

9091
void wt_status_prepare(struct wt_status *s);

0 commit comments

Comments
 (0)