rebase -i: handle "Nothing to do" case with autostash
When a user invokes $ git rebase -i @~3 with dirty files and rebase.autostash turned on, and exits the $EDITOR with an empty buffer, the autostash fails to apply. Although the primary focus of rr/rebase-autostash was to get the git-rebase--backend.sh scripts to return control to git-rebase.sh, it missed this case in git-rebase--interactive.sh. Since this case is unlike the other cases which return control for housekeeping, assign it a special return status and handle that return value explicitly in git-rebase.sh. Reported-by: Karen Etheridge <ether@cpan.org> Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Ramkumar Ramachandra committed
May 19, 2014 at 18:05 UTC
e4244eb3957d478ca05b42d8b56aadb9ab2bc7ae
2 files changed
+12
-3
git-rebase--interactive.sh
+2
-2
@@ -970,14 +970,14 @@ fi
970
971
972
has_action "$todo" ||
973
- die_abort "Nothing to do"
973
+ return 2
974
975
cp "$todo" "$todo".backup
976
git_sequence_editor "$todo" ||
977
die_abort "Could not execute editor"
978
979
has_action "$todo" ||
980
- die_abort "Nothing to do"
980
+ return 2
981
982
test -d "$rewritten" || test -n "$force_rebase" || skip_unnecessary_picks
983
git-rebase.sh
+10
-1
@@ -147,7 +147,7 @@ move_to_original_branch () {
147
esac
148
}
149
150
-finish_rebase () {
150
+apply_autostash () {
151
if test -f "$state_dir/autostash"
152
then
153
stash_sha1=$(cat "$state_dir/autostash")
@@ -166,6 +166,10 @@ You can run "git stash pop" or "git stash drop" at any time.
166
'
167
fi
168
fi
169
+}
170
+
171
+finish_rebase () {
172
+ apply_autostash &&
173
git gc --auto &&
174
rm -rf "$state_dir"
175
}
@@ -181,6 +185,11 @@ run_specific_rebase () {
185
if test $ret -eq 0
186
then
187
finish_rebase
188
+ elif test $ret -eq 2 # special exit status for rebase -i
189
+ then
190
+ apply_autostash &&
191
+ rm -rf "$state_dir" &&
192
+ die "Nothing to do"
193
fi
194
exit $ret
195
}