rebase -i: use a better reflog message

Now that the "checkout" invoked internally from "rebase -i" knows to honor GIT_REFLOG_ACTION, we can start to use it to write a better reflog message when "rebase anotherbranch", "rebase --onto branch", etc. internally checks out the new fork point. We will write: rebase -i: checkout master instead of the old rebase -i As all the calls git-rebase--interactive make to underlying git commands that leave reflog messages are preceded by the internal comment_for_reflog helper function, which uses the original value of the GIT_REFLOG_ACTION variable it saw when it first started, the new assignments to GIT_REFLOG_ACTION actively contaminate the value of the variable, knowing that it will be reset to a sane value before it is used again. This does not generally hold true but it should suffice for now. Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ramkumar Ramachandra committed Jun 16, 2013 at 14:15 UTC 26cd160cb15635afd1c2937a3c15cfb256758323
2 files changed +20 -1
git-rebase--interactive.sh
+5 -1
@@ -837,8 +837,11 @@ comment_for_reflog start
837
838 if test ! -z "$switch_to"
839 then
840 + GIT_REFLOG_ACTION="$GIT_REFLOG_ACTION: checkout $switch_to"
841 output git checkout "$switch_to" -- ||
841 - die "Could not checkout $switch_to"
842 + die "Could not checkout $switch_to"
843 +
844 + comment_for_reflog start
845 fi
846
847 orig_head=$(git rev-parse --verify HEAD) || die "No HEAD?"
@@ -980,6 +983,7 @@ has_action "$todo" ||
983
984 test -d "$rewritten" || test -n "$force_rebase" || skip_unnecessary_picks
985
986 +GIT_REFLOG_ACTION="$GIT_REFLOG_ACTION: checkout $onto_name"
987 output git checkout $onto || die_abort "could not detach HEAD"
988 git update-ref ORIG_HEAD $orig_head
989 do_rest
t/t3404-rebase-interactive.sh
+15
@@ -934,6 +934,21 @@ test_expect_success 'rebase --edit-todo can be used to modify todo' '
934 test L = $(git cat-file commit HEAD | sed -ne \$p)
935 '
936
937 +test_expect_success 'rebase -i produces readable reflog' '
938 + git reset --hard &&
939 + git branch -f branch-reflog-test H &&
940 + git rebase -i --onto I F branch-reflog-test &&
941 + cat >expect <<-\EOF &&
942 + rebase -i (start): checkout I
943 + rebase -i (pick): G
944 + rebase -i (pick): H
945 + rebase -i (finish): returning to refs/heads/branch-reflog-test
946 + EOF
947 + tail -n 4 .git/logs/HEAD |
948 + sed -e "s/.* //" >actual &&
949 + test_cmp expect actual
950 +'
951 +
952 test_expect_success 'rebase -i respects core.commentchar' '
953 git reset --hard &&
954 git checkout E^0 &&