diff options
author | Junio C Hamano <gitster@pobox.com> | 2011-10-05 12:35:52 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2011-10-05 12:35:52 -0700 |
commit | 2c4610393195cc6f35ea79efadbc5c7fd7470891 (patch) | |
tree | b422689e144f11fc7ded37c809607bc8fb3eee96 | |
parent | Git 1.7.7 (diff) | |
parent | rebase -i: notice and warn if "exec $cmd" modifies the index or the working tree (diff) | |
download | tgif-2c4610393195cc6f35ea79efadbc5c7fd7470891.tar.xz |
Merge branch 'mm/rebase-i-exec-edit'
* mm/rebase-i-exec-edit:
rebase -i: notice and warn if "exec $cmd" modifies the index or the working tree
rebase -i: clean error message for --continue after failed exec
-rw-r--r-- | git-rebase--interactive.sh | 30 | ||||
-rwxr-xr-x | t/t3404-rebase-interactive.sh | 14 |
2 files changed, 40 insertions, 4 deletions
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh index c6ba7c1551..94f36c254c 100644 --- a/git-rebase--interactive.sh +++ b/git-rebase--interactive.sh @@ -472,18 +472,24 @@ do_next () { git rev-parse --verify HEAD > "$state_dir"/stopped-sha ${SHELL:-@SHELL_PATH@} -c "$rest" # Actual execution 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 then 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 warn " git rebase --continue" warn exit "$status" - fi - # Run in subshell because require_clean_work_tree can die. - if ! (require_clean_work_tree "rebase") + elif test "$dirty" = t 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 warn " git rebase --continue" @@ -647,8 +653,24 @@ continue) then : Nothing to commit -- skip this else + if ! test -f "$author_script" + then + die "You have staged changes in your working tree. If these changes are meant to be +squashed into the previous commit, run: + + git commit --amend + +If they are meant to go into a new commit, run: + + git commit + +In both case, once you're done, continue with: + + git rebase --continue +" + fi . "$author_script" || - die "Cannot find the author identity" + die "Error trying to find the author identity to amend commit" current_head= if test -f "$amend" then diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index 8538813d1d..b981572d73 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -527,6 +527,20 @@ test_expect_success 'auto-amend only edited commits after "edit"' ' git rebase --abort ' +test_expect_success 'clean error after failed "exec"' ' + test_tick && + test_when_finished "git rebase --abort || :" && + ( + FAKE_LINES="1 exec_false" && + export FAKE_LINES && + test_must_fail git rebase -i HEAD^ + ) && + echo "edited again" > file7 && + git add file7 && + test_must_fail git rebase --continue 2>error && + grep "You have staged changes in your working tree." error +' + test_expect_success 'rebase a detached HEAD' ' grandparent=$(git rev-parse HEAD~2) && git checkout $(git rev-parse HEAD) && |