Merge branch 'ps/rebase-i-auto-unstash-upon-abort' into maint
authorJunio C Hamano <gitster@pobox.com>
Thu, 28 Jul 2016 18:25:52 +0000 (11:25 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 28 Jul 2016 18:25:52 +0000 (11:25 -0700)
"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

git-rebase--interactive.sh
t/t3420-rebase-autostash.sh
index 05f22e43ccfe485b2a676f96ddec1a99f7a84612..4f499d2c13e7a891aa46b23fcb27308b52b0d235 100644 (file)
@@ -212,6 +212,7 @@ exit_with_patch () {
 }
 
 die_abort () {
+       apply_autostash
        rm -rf "$state_dir"
        die "$1"
 }
index 944154b2e0ad7da5ddacdde5c22847babf1909c9..532ff5cbd1cbbce8bdbc83660d3084b938886c60 100755 (executable)
@@ -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 abort-editor.sh <<-\EOF &&
+                       echo conflicting-content >file0
+                       exit 1
+               EOF
+               test_set_editor "$(pwd)/abort-editor.sh" &&
+               test_must_fail git rebase -i --autostash HEAD^ &&
+               rm -f abort-editor.sh
+       ) &&
+       echo conflicting-content >expected &&
+       test_cmp expected file0 &&
+       git checkout file0 &&
+       git stash pop &&
+       echo uncommitted-content >expected &&
+       test_cmp expected file0
+'
+
 test_done