Skip to content

Commit afbfcaa

Browse files
committed
Merge branch 'rr/rebase-reflog-message-reword'
"git rebase [-i]" used to leave just "rebase" as its reflog message for some operations. This rewords them to be more informative. * rr/rebase-reflog-message-reword: rebase -i: use a better reflog message rebase: use a better reflog message
2 parents 001b097 + 26cd160 commit afbfcaa

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

git-rebase--interactive.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -864,8 +864,11 @@ comment_for_reflog start
864864

865865
if test ! -z "$switch_to"
866866
then
867+
GIT_REFLOG_ACTION="$GIT_REFLOG_ACTION: checkout $switch_to"
867868
output git checkout "$switch_to" -- ||
868-
die "Could not checkout $switch_to"
869+
die "Could not checkout $switch_to"
870+
871+
comment_for_reflog start
869872
fi
870873

871874
orig_head=$(git rev-parse --verify HEAD) || die "No HEAD?"
@@ -1007,6 +1010,7 @@ has_action "$todo" ||
10071010

10081011
test -d "$rewritten" || test -n "$force_rebase" || skip_unnecessary_picks
10091012

1013+
GIT_REFLOG_ACTION="$GIT_REFLOG_ACTION: checkout $onto_name"
10101014
output git checkout $onto || die_abort "could not detach HEAD"
10111015
git update-ref ORIG_HEAD $orig_head
10121016
do_rest

git-rebase.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,9 @@ then
542542
if test -z "$force_rebase"
543543
then
544544
# Lazily switch to the target branch if needed...
545-
test -z "$switch_to" || git checkout "$switch_to" --
545+
test -z "$switch_to" ||
546+
GIT_REFLOG_ACTION="$GIT_REFLOG_ACTION: checkout $switch_to" \
547+
git checkout "$switch_to" --
546548
say "$(eval_gettext "Current branch \$branch_name is up to date.")"
547549
finish_rebase
548550
exit 0
@@ -568,7 +570,9 @@ test "$type" = interactive && run_specific_rebase
568570

569571
# Detach HEAD and reset the tree
570572
say "$(gettext "First, rewinding head to replay your work on top of it...")"
571-
git checkout -q "$onto^0" || die "could not detach HEAD"
573+
574+
GIT_REFLOG_ACTION="$GIT_REFLOG_ACTION: checkout $onto_name" \
575+
git checkout -q "$onto^0" || die "could not detach HEAD"
572576
git update-ref ORIG_HEAD $orig_head
573577

574578
# If the $onto is a proper descendant of the tip of the branch, then

t/t3404-rebase-interactive.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -926,6 +926,21 @@ test_expect_success 'rebase --edit-todo can be used to modify todo' '
926926
test L = $(git cat-file commit HEAD | sed -ne \$p)
927927
'
928928

929+
test_expect_success 'rebase -i produces readable reflog' '
930+
git reset --hard &&
931+
git branch -f branch-reflog-test H &&
932+
git rebase -i --onto I F branch-reflog-test &&
933+
cat >expect <<-\EOF &&
934+
rebase -i (start): checkout I
935+
rebase -i (pick): G
936+
rebase -i (pick): H
937+
rebase -i (finish): returning to refs/heads/branch-reflog-test
938+
EOF
939+
tail -n 4 .git/logs/HEAD |
940+
sed -e "s/.* //" >actual &&
941+
test_cmp expect actual
942+
'
943+
929944
test_expect_success 'rebase -i respects core.commentchar' '
930945
git reset --hard &&
931946
git checkout E^0 &&

0 commit comments

Comments
 (0)