Skip to content

Commit 37ad7ca

Browse files
committed
Merge branch 'mz/rebase-abort-reflog-fix' into maint
* mz/rebase-abort-reflog-fix: rebase --abort: do not update branch ref
2 parents e0cbf12 + 729ec9e commit 37ad7ca

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

git-rebase.sh

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -275,15 +275,16 @@ do
275275
die "No rebase in progress?"
276276

277277
git rerere clear
278-
if test -d "$dotest"
279-
then
280-
GIT_QUIET=$(cat "$dotest/quiet")
281-
move_to_original_branch
282-
else
283-
dotest="$GIT_DIR"/rebase-apply
284-
GIT_QUIET=$(cat "$dotest/quiet")
285-
move_to_original_branch
286-
fi
278+
279+
test -d "$dotest" || dotest="$GIT_DIR"/rebase-apply
280+
281+
head_name="$(cat "$dotest"/head-name)" &&
282+
case "$head_name" in
283+
refs/*)
284+
git symbolic-ref HEAD $head_name ||
285+
die "Could not move back to $head_name"
286+
;;
287+
esac
287288
git reset --hard $(cat "$dotest/orig-head")
288289
rm -r "$dotest"
289290
exit

t/t3407-rebase-abort.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,18 @@ testrebase() {
7272
test $(git rev-parse to-rebase) = $(git rev-parse pre-rebase) &&
7373
test ! -d "$dotest"
7474
'
75+
76+
test_expect_success "rebase$type --abort does not update reflog" '
77+
cd "$work_dir" &&
78+
# Clean up the state from the previous one
79+
git reset --hard pre-rebase &&
80+
git reflog show to-rebase > reflog_before &&
81+
test_must_fail git rebase$type master &&
82+
git rebase --abort &&
83+
git reflog show to-rebase > reflog_after &&
84+
test_cmp reflog_before reflog_after &&
85+
rm reflog_before reflog_after
86+
'
7587
}
7688

7789
testrebase "" .git/rebase-apply

0 commit comments

Comments
 (0)