status: show commit sha1 in "You are currently reverting" message
authorMatthieu Moy <Matthieu.Moy@imag.fr>
Tue, 2 Apr 2013 14:20:22 +0000 (16:20 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 2 Apr 2013 21:22:56 +0000 (14:22 -0700)
Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t7512-status-help.sh
wt-status.c
wt-status.h
index d745cf4e5f8a6f24b60fd9c26bd1453310f881e3..bf08d4e098f1bdc3adc5ec3df37b90d90b0e5c8f 100755 (executable)
@@ -686,10 +686,11 @@ test_expect_success 'status while reverting commit (conflicts)' '
        test_commit old to-revert.txt &&
        echo new >to-revert.txt &&
        test_commit new to-revert.txt &&
-       test_must_fail git revert HEAD^ &&
+       TO_REVERT=$(git rev-parse --short HEAD^) &&
+       test_must_fail git revert $TO_REVERT &&
        cat >expected <<-EOF
        # On branch master
-       # You are currently reverting a commit.
+       # You are currently reverting commit $TO_REVERT.
        #   (fix conflicts and run "git revert --continue")
        #   (use "git revert --abort" to cancel the revert operation)
        #
@@ -710,7 +711,7 @@ test_expect_success 'status while reverting commit (conflicts resolved)' '
        git add to-revert.txt &&
        cat >expected <<-EOF
        # On branch master
-       # You are currently reverting a commit.
+       # You are currently reverting commit $TO_REVERT.
        #   (all conflicts fixed: run "git revert --continue")
        #   (use "git revert --abort" to cancel the revert operation)
        #
index 39f888bcc8b6cb4a32442972a7649b2825dd4d3f..09416db348cb0e5e1bfc1fe82878c9afe627e09f 100644 (file)
@@ -969,7 +969,8 @@ static void show_revert_in_progress(struct wt_status *s,
                                        struct wt_status_state *state,
                                        const char *color)
 {
-       status_printf_ln(s, color, _("You are currently reverting a commit."));
+       status_printf_ln(s, color, _("You are currently reverting commit %s."),
+                        find_unique_abbrev(state->revert_head_sha1, DEFAULT_ABBREV));
        if (advice_status_hints) {
                if (has_unmerged(s))
                        status_printf_ln(s, color,
@@ -1104,6 +1105,7 @@ void wt_status_get_state(struct wt_status_state *state,
                         int get_detached_from)
 {
        struct stat st;
+       unsigned char sha1[20];
 
        if (!stat(git_path("MERGE_HEAD"), &st)) {
                state->merge_in_progress = 1;
@@ -1131,8 +1133,10 @@ void wt_status_get_state(struct wt_status_state *state,
                state->bisect_in_progress = 1;
                state->branch = read_and_strip_branch("BISECT_START");
        }
-       if (!stat(git_path("REVERT_HEAD"), &st)) {
+       if (!stat(git_path("REVERT_HEAD"), &st) &&
+           !get_sha1("REVERT_HEAD", sha1)) {
                state->revert_in_progress = 1;
+               hashcpy(state->revert_head_sha1, sha1);
        }
 
        if (get_detached_from)
index 35cd6cb669d48a7029c74c325167b92721b3a0ac..4121bc208db2fbe5e4eb00af10056a9d8c0bab40 100644 (file)
@@ -85,6 +85,7 @@ struct wt_status_state {
        char *onto;
        char *detached_from;
        unsigned char detached_sha1[20];
+       unsigned char revert_head_sha1[20];
 };
 
 void wt_status_prepare(struct wt_status *s);