Skip to content

Commit 1686519

Browse files
committed
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 <[email protected]>
1 parent ffaaed8 commit 1686519

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

git-rebase--interactive.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -472,18 +472,24 @@ do_next () {
472472
git rev-parse --verify HEAD > "$state_dir"/stopped-sha
473473
${SHELL:-@SHELL_PATH@} -c "$rest" # Actual execution
474474
status=$?
475+
# Run in subshell because require_clean_work_tree can die.
476+
dirty=f
477+
(require_clean_work_tree "rebase" 2>/dev/null) || dirty=t
475478
if test "$status" -ne 0
476479
then
477480
warn "Execution failed: $rest"
481+
test "$dirty" = f ||
482+
warn "and made changes to the index and/or the working tree"
483+
478484
warn "You can fix the problem, and then run"
479485
warn
480486
warn " git rebase --continue"
481487
warn
482488
exit "$status"
483-
fi
484-
# Run in subshell because require_clean_work_tree can die.
485-
if ! (require_clean_work_tree "rebase")
489+
elif test "$dirty" = t
486490
then
491+
warn "Execution succeeded: $rest"
492+
warn "but left changes to the index and/or the working tree"
487493
warn "Commit or stash your changes, and then run"
488494
warn
489495
warn " git rebase --continue"

0 commit comments

Comments
 (0)