aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2014-06-16 10:06:57 -0700
committerJunio C Hamano <gitster@pobox.com>2014-06-16 10:06:57 -0700
commit4a43d4f98a1a6a472ce1e87c64cb6df0d1653d02 (patch)
tree298f55985603d82fbf0b56512e3a434dc08242a6
parent9d1d882e9c1d4a34e2ae3af47d50c1f115a6cf84 (diff)
parentddb5432d2390e1957e473618009ba3d2fbbf29a7 (diff)
downloadgit-4a43d4f98a1a6a472ce1e87c64cb6df0d1653d02.tar.gz
git-4a43d4f98a1a6a472ce1e87c64cb6df0d1653d02.tar.xz
Merge branch 'rr/rebase-autostash-fix'
* rr/rebase-autostash-fix: rebase -i: test "Nothing to do" case with autostash rebase -i: handle "Nothing to do" case with autostash
-rw-r--r--git-rebase--interactive.sh4
-rwxr-xr-xgit-rebase.sh11
-rwxr-xr-xt/t3420-rebase-autostash.sh15
3 files changed, 27 insertions, 3 deletions
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 6ec9d3cb4..f267d8b6c 100644
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -1049,14 +1049,14 @@ fi
has_action "$todo" ||
- die_abort "Nothing to do"
+ return 2
cp "$todo" "$todo".backup
git_sequence_editor "$todo" ||
die_abort "Could not execute editor"
has_action "$todo" ||
- die_abort "Nothing to do"
+ return 2
expand_todo_ids
diff --git a/git-rebase.sh b/git-rebase.sh
index 5c7a0a1a5..06c810b64 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -155,7 +155,7 @@ move_to_original_branch () {
esac
}
-finish_rebase () {
+apply_autostash () {
if test -f "$state_dir/autostash"
then
stash_sha1=$(cat "$state_dir/autostash")
@@ -171,6 +171,10 @@ You can run "git stash pop" or "git stash drop" at any time.
'
fi
fi
+}
+
+finish_rebase () {
+ apply_autostash &&
git gc --auto &&
rm -rf "$state_dir"
}
@@ -186,6 +190,11 @@ run_specific_rebase () {
if test $ret -eq 0
then
finish_rebase
+ elif test $ret -eq 2 # special exit status for rebase -i
+ then
+ apply_autostash &&
+ rm -rf "$state_dir" &&
+ die "Nothing to do"
fi
exit $ret
}
diff --git a/t/t3420-rebase-autostash.sh b/t/t3420-rebase-autostash.sh
index 90eb26493..d783f03d3 100755
--- a/t/t3420-rebase-autostash.sh
+++ b/t/t3420-rebase-autostash.sh
@@ -167,4 +167,19 @@ testrebase "" .git/rebase-apply
testrebase " --merge" .git/rebase-merge
testrebase " --interactive" .git/rebase-merge
+test_expect_success 'abort rebase -i with --autostash' '
+ test_when_finished "git reset --hard" &&
+ echo uncommited-content >file0 &&
+ (
+ write_script abort-editor.sh <<-\EOF &&
+ echo >"$1"
+ EOF
+ test_set_editor "$(pwd)/abort-editor.sh" &&
+ test_must_fail git rebase -i --autostash HEAD^ &&
+ rm -f abort-editor.sh
+ ) &&
+ echo uncommited-content >expected &&
+ test_cmp expected file0
+'
+
test_done