Skip to content

Commit ae8daba

Browse files
committed
Merge branch 'ps/rebase-i-auto-unstash-upon-abort' into maint
"git rebase -i --autostash" did not restore the auto-stashed change when the operation was aborted. * ps/rebase-i-auto-unstash-upon-abort: rebase -i: restore autostash on abort
2 parents c12c71f + 33ba9c6 commit ae8daba

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

git-rebase--interactive.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ exit_with_patch () {
212212
}
213213

214214
die_abort () {
215+
apply_autostash
215216
rm -rf "$state_dir"
216217
die "$1"
217218
}

t/t3420-rebase-autostash.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,4 +192,35 @@ test_expect_success 'abort rebase -i with --autostash' '
192192
test_cmp expected file0
193193
'
194194

195+
test_expect_success 'restore autostash on editor failure' '
196+
test_when_finished "git reset --hard" &&
197+
echo uncommitted-content >file0 &&
198+
(
199+
test_set_editor "false" &&
200+
test_must_fail git rebase -i --autostash HEAD^
201+
) &&
202+
echo uncommitted-content >expected &&
203+
test_cmp expected file0
204+
'
205+
206+
test_expect_success 'autostash is saved on editor failure with conflict' '
207+
test_when_finished "git reset --hard" &&
208+
echo uncommitted-content >file0 &&
209+
(
210+
write_script abort-editor.sh <<-\EOF &&
211+
echo conflicting-content >file0
212+
exit 1
213+
EOF
214+
test_set_editor "$(pwd)/abort-editor.sh" &&
215+
test_must_fail git rebase -i --autostash HEAD^ &&
216+
rm -f abort-editor.sh
217+
) &&
218+
echo conflicting-content >expected &&
219+
test_cmp expected file0 &&
220+
git checkout file0 &&
221+
git stash pop &&
222+
echo uncommitted-content >expected &&
223+
test_cmp expected file0
224+
'
225+
195226
test_done

0 commit comments

Comments
 (0)