Skip to content

Commit e4244eb

Browse files
artagnongitster
authored andcommitted
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 <[email protected]> Signed-off-by: Ramkumar Ramachandra <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ac1998d commit e4244eb

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

git-rebase--interactive.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -970,14 +970,14 @@ fi
970970

971971

972972
has_action "$todo" ||
973-
die_abort "Nothing to do"
973+
return 2
974974

975975
cp "$todo" "$todo".backup
976976
git_sequence_editor "$todo" ||
977977
die_abort "Could not execute editor"
978978

979979
has_action "$todo" ||
980-
die_abort "Nothing to do"
980+
return 2
981981

982982
test -d "$rewritten" || test -n "$force_rebase" || skip_unnecessary_picks
983983

git-rebase.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ move_to_original_branch () {
147147
esac
148148
}
149149

150-
finish_rebase () {
150+
apply_autostash () {
151151
if test -f "$state_dir/autostash"
152152
then
153153
stash_sha1=$(cat "$state_dir/autostash")
@@ -166,6 +166,10 @@ You can run "git stash pop" or "git stash drop" at any time.
166166
'
167167
fi
168168
fi
169+
}
170+
171+
finish_rebase () {
172+
apply_autostash &&
169173
git gc --auto &&
170174
rm -rf "$state_dir"
171175
}
@@ -181,6 +185,11 @@ run_specific_rebase () {
181185
if test $ret -eq 0
182186
then
183187
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"
184193
fi
185194
exit $ret
186195
}

0 commit comments

Comments
 (0)