rebase -i: notice and warn if "exec $cmd" modifies the index or the working tree

If "exec $cmd" touched the index or the working tree, and exited with
non-zero status, the code did not check and warn that there now are
uncommitted changes.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Junio C Hamano 2011-08-24 11:54:50 -07:00
parent ffaaed88ae
commit 1686519a08

View File

@ -472,18 +472,24 @@ do_next () {
git rev-parse --verify HEAD > "$state_dir"/stopped-sha git rev-parse --verify HEAD > "$state_dir"/stopped-sha
${SHELL:-@SHELL_PATH@} -c "$rest" # Actual execution ${SHELL:-@SHELL_PATH@} -c "$rest" # Actual execution
status=$? status=$?
# Run in subshell because require_clean_work_tree can die.
dirty=f
(require_clean_work_tree "rebase" 2>/dev/null) || dirty=t
if test "$status" -ne 0 if test "$status" -ne 0
then then
warn "Execution failed: $rest" warn "Execution failed: $rest"
test "$dirty" = f ||
warn "and made changes to the index and/or the working tree"
warn "You can fix the problem, and then run" warn "You can fix the problem, and then run"
warn warn
warn " git rebase --continue" warn " git rebase --continue"
warn warn
exit "$status" exit "$status"
fi elif test "$dirty" = t
# Run in subshell because require_clean_work_tree can die.
if ! (require_clean_work_tree "rebase")
then then
warn "Execution succeeded: $rest"
warn "but left changes to the index and/or the working tree"
warn "Commit or stash your changes, and then run" warn "Commit or stash your changes, and then run"
warn warn
warn " git rebase --continue" warn " git rebase --continue"