Merge branch 'rt/cherry-pick-status'
authorJonathan Nieder <jrnieder@gmail.com>
Mon, 14 Oct 2013 18:08:47 +0000 (11:08 -0700)
committerJonathan Nieder <jrnieder@gmail.com>
Mon, 14 Oct 2013 18:08:47 +0000 (11:08 -0700)
* rt/cherry-pick-status:
status: show commit sha1 in "You are currently cherry-picking" message
status test: add missing && to <<EOF blocks

t/t7512-status-help.sh
wt-status.c
wt-status.h
index 0688d58884962c4e0bcfb89191602a36131ebf92..3cec57af1ee0ca8ccbbbdc47871cd4ff07e0d034 100755 (executable)
@@ -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)
 
@@ -669,7 +671,7 @@ EOF
 test_expect_success 'status showing detached at and from a tag' '
        test_commit atag tagging &&
        git checkout atag &&
-       cat >expected <<\EOF
+       cat >expected <<\EOF &&
 HEAD detached at atag
 nothing to commit (use -u to show untracked files)
 EOF
@@ -677,7 +679,7 @@ EOF
        test_i18ncmp expected actual &&
 
        git reset --hard HEAD^ &&
-       cat >expected <<\EOF
+       cat >expected <<\EOF &&
 HEAD detached from atag
 nothing to commit (use -u to show untracked files)
 EOF
@@ -695,7 +697,7 @@ test_expect_success 'status while reverting commit (conflicts)' '
        test_commit new to-revert.txt &&
        TO_REVERT=$(git rev-parse --short HEAD^) &&
        test_must_fail git revert $TO_REVERT &&
-       cat >expected <<EOF
+       cat >expected <<EOF &&
 On branch master
 You are currently reverting commit $TO_REVERT.
   (fix conflicts and run "git revert --continue")
@@ -716,7 +718,7 @@ EOF
 test_expect_success 'status while reverting commit (conflicts resolved)' '
        echo reverted >to-revert.txt &&
        git add to-revert.txt &&
-       cat >expected <<EOF
+       cat >expected <<EOF &&
 On branch master
 You are currently reverting commit $TO_REVERT.
   (all conflicts fixed: run "git revert --continue")
@@ -735,7 +737,7 @@ EOF
 
 test_expect_success 'status after reverting commit' '
        git revert --continue &&
-       cat >expected <<\EOF
+       cat >expected <<\EOF &&
 On branch master
 nothing to commit (use -u to show untracked files)
 EOF
index cbdce726512f3daa5ad574c3aae07ed25b80c502..b4e44baa2917dfcf33824c3d6fc08756886b9ae1 100644 (file)
@@ -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;
index 9341c569a52e53cc939fa3bd94e013bbc2c8444d..6c29e6f5e57f84eb7acdc3cf1ee621cc717fd5a9 100644 (file)
@@ -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);