Skip to content

Commit 53f2ffa

Browse files
peffgitster
authored andcommitted
rebase: write a reflog entry when finishing
When we finish a rebase, our detached HEAD is at the final result. We update the original branch ref with this result, and then point the HEAD symbolic ref at the updated branch. We write a reflog for the branch update, but not for the update of HEAD. Because we're already at the final result on the detached HEAD, moving to the branch actually doesn't change our commit sha1 at all. So in that sense, a reflog entry would be pointless. However, humans do read reflogs, and an entry saying "rebase finished: returning to refs/heads/master" can be helpful in understanding what is going on. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ea69619 commit 53f2ffa

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

git-rebase--interactive.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,9 @@ do_next () {
510510
refs/*)
511511
message="$GIT_REFLOG_ACTION: $head_name onto $shortonto" &&
512512
git update-ref -m "$message" $head_name $newhead $orig_head &&
513-
git symbolic-ref HEAD $head_name
513+
git symbolic-ref \
514+
-m "$GIT_REFLOG_ACTION: returning to $head_name" \
515+
HEAD $head_name
514516
;;
515517
esac && {
516518
test ! -f "$state_dir"/verbose ||

git-rebase.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,9 @@ move_to_original_branch () {
153153
message="rebase finished: $head_name onto $onto"
154154
git update-ref -m "$message" \
155155
$head_name $(git rev-parse HEAD) $orig_head &&
156-
git symbolic-ref HEAD $head_name ||
156+
git symbolic-ref \
157+
-m "rebase finished: returning to $head_name" \
158+
HEAD $head_name ||
157159
die "Could not move back to $head_name"
158160
;;
159161
esac

t/t3404-rebase-interactive.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ test_expect_success '--continue tries to commit' '
317317
'
318318

319319
test_expect_success 'verbose flag is heeded, even after --continue' '
320-
git reset --hard HEAD@{1} &&
320+
git reset --hard master@{1} &&
321321
test_tick &&
322322
test_must_fail git rebase -v -i --onto new-branch1 HEAD^ &&
323323
echo resolved > file1 &&

0 commit comments

Comments
 (0)