Skip to content

Commit afaa2a4

Browse files
committed
Merge branch 'rr/rebase-autostash'
* rr/rebase-autostash: rebase: finish_rebase() in noop rebase rebase: finish_rebase() in fast-forward rebase rebase: guard against missing files in read_basic_state()
2 parents 352e86e + 96e2b99 commit afaa2a4

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

git-rebase.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ keep_empty=
8484
test "$(git config --bool rebase.autosquash)" = "true" && autosquash=t
8585

8686
read_basic_state () {
87+
test -f "$state_dir/head-name" &&
88+
test -f "$state_dir/onto" &&
8789
head_name=$(cat "$state_dir"/head-name) &&
8890
onto=$(cat "$state_dir"/onto) &&
8991
# We always write to orig-head, but interactive rebase used to write to
@@ -545,6 +547,7 @@ then
545547
# Lazily switch to the target branch if needed...
546548
test -z "$switch_to" || git checkout "$switch_to" --
547549
say "$(eval_gettext "Current branch \$branch_name is up to date.")"
550+
finish_rebase
548551
exit 0
549552
else
550553
say "$(eval_gettext "Current branch \$branch_name is up to date, rebase forced.")"
@@ -577,6 +580,7 @@ if test "$mb" = "$orig_head"
577580
then
578581
say "$(eval_gettext "Fast-forwarded \$branch_name to \$onto_name.")"
579582
move_to_original_branch
583+
finish_rebase
580584
exit 0
581585
fi
582586

t/t3420-rebase-autostash.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,28 @@ testrebase() {
141141
'
142142
}
143143

144+
test_expect_success "rebase: fast-forward rebase" '
145+
test_config rebase.autostash true &&
146+
git reset --hard &&
147+
git checkout -b behind-feature-branch feature-branch~1 &&
148+
test_when_finished git branch -D behind-feature-branch &&
149+
echo dirty >>file1 &&
150+
git rebase feature-branch &&
151+
grep dirty file1 &&
152+
git checkout feature-branch
153+
'
154+
155+
test_expect_success "rebase: noop rebase" '
156+
test_config rebase.autostash true &&
157+
git reset --hard &&
158+
git checkout -b same-feature-branch feature-branch &&
159+
test_when_finished git branch -D same-feature-branch &&
160+
echo dirty >>file1 &&
161+
git rebase feature-branch &&
162+
grep dirty file1 &&
163+
git checkout feature-branch
164+
'
165+
144166
testrebase "" .git/rebase-apply
145167
testrebase " --merge" .git/rebase-merge
146168
testrebase " --interactive" .git/rebase-merge

0 commit comments

Comments
 (0)