Skip to content
Browse files

rebase -i: restore autostash on abort

When we abort an interactive rebase we do so by calling
`die_abort`, which cleans up after us by removing the rebase
state directory. If the user has requested to use the autostash
feature, though, the state directory may also contain a reference
to the autostash, which will now be deleted.

Fix the issue by trying to re-apply the autostash in `die_abort`.
This will also handle the case where the autostash does not apply
cleanly anymore by recording it in a user-visible stash.

Reported-by: Daniel Hahler <>
Signed-off-by: Patrick Steinhardt <>
Signed-off-by: Junio C Hamano <>
  • Loading branch information...
pks-t authored and gitster committed Jun 29, 2016
1 parent e465796 commit 33ba9c648b6753a4184e53ffb89f0a924f9f7b7e
Showing with 32 additions and 0 deletions.
  1. +1 −0
  2. +31 −0 t/
@@ -216,6 +216,7 @@ exit_with_patch () {

die_abort () {
rm -rf "$state_dir"
die "$1"
@@ -192,4 +192,35 @@ test_expect_success 'abort rebase -i with --autostash' '
test_cmp expected file0

test_expect_success 'restore autostash on editor failure' '
test_when_finished "git reset --hard" &&
echo uncommitted-content >file0 &&
test_set_editor "false" &&
test_must_fail git rebase -i --autostash HEAD^
) &&
echo uncommitted-content >expected &&
test_cmp expected file0

test_expect_success 'autostash is saved on editor failure with conflict' '
test_when_finished "git reset --hard" &&
echo uncommitted-content >file0 &&
write_script <<-\EOF &&
echo conflicting-content >file0
exit 1
test_set_editor "$(pwd)/" &&
test_must_fail git rebase -i --autostash HEAD^ &&
rm -f
) &&
echo conflicting-content >expected &&
test_cmp expected file0 &&
git checkout file0 &&
git stash pop &&
echo uncommitted-content >expected &&
test_cmp expected file0


0 comments on commit 33ba9c6

Please sign in to comment.
You can’t perform that action at this time.