Skip to content

Commit

Permalink
Merge branch 'rr/rebase-reflog-message-reword'
Browse files Browse the repository at this point in the history
"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
  • Loading branch information
Junio C Hamano committed Jul 18, 2013
2 parents 001b097 + 26cd160 commit afbfcaa
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
6 changes: 5 additions & 1 deletion git-rebase--interactive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -864,8 +864,11 @@ comment_for_reflog start

if test ! -z "$switch_to"
then
GIT_REFLOG_ACTION="$GIT_REFLOG_ACTION: checkout $switch_to"
output git checkout "$switch_to" -- ||
die "Could not checkout $switch_to"
die "Could not checkout $switch_to"

comment_for_reflog start
fi

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

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

GIT_REFLOG_ACTION="$GIT_REFLOG_ACTION: checkout $onto_name"
output git checkout $onto || die_abort "could not detach HEAD"
git update-ref ORIG_HEAD $orig_head
do_rest
8 changes: 6 additions & 2 deletions git-rebase.sh
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,9 @@ then
if test -z "$force_rebase"
then
# Lazily switch to the target branch if needed...
test -z "$switch_to" || git checkout "$switch_to" --
test -z "$switch_to" ||
GIT_REFLOG_ACTION="$GIT_REFLOG_ACTION: checkout $switch_to" \
git checkout "$switch_to" --
say "$(eval_gettext "Current branch \$branch_name is up to date.")"
finish_rebase
exit 0
Expand All @@ -568,7 +570,9 @@ test "$type" = interactive && run_specific_rebase

# Detach HEAD and reset the tree
say "$(gettext "First, rewinding head to replay your work on top of it...")"
git checkout -q "$onto^0" || die "could not detach HEAD"

GIT_REFLOG_ACTION="$GIT_REFLOG_ACTION: checkout $onto_name" \
git checkout -q "$onto^0" || die "could not detach HEAD"
git update-ref ORIG_HEAD $orig_head

# If the $onto is a proper descendant of the tip of the branch, then
Expand Down
15 changes: 15 additions & 0 deletions t/t3404-rebase-interactive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,21 @@ test_expect_success 'rebase --edit-todo can be used to modify todo' '
test L = $(git cat-file commit HEAD | sed -ne \$p)
'

test_expect_success 'rebase -i produces readable reflog' '
git reset --hard &&
git branch -f branch-reflog-test H &&
git rebase -i --onto I F branch-reflog-test &&
cat >expect <<-\EOF &&
rebase -i (start): checkout I
rebase -i (pick): G
rebase -i (pick): H
rebase -i (finish): returning to refs/heads/branch-reflog-test
EOF
tail -n 4 .git/logs/HEAD |
sed -e "s/.* //" >actual &&
test_cmp expect actual
'

test_expect_success 'rebase -i respects core.commentchar' '
git reset --hard &&
git checkout E^0 &&
Expand Down

0 comments on commit afbfcaa

Please sign in to comment.