The to-do list command `reword` replays a commit like `pick` but lets the user also edit the commit's log message. This happens in two steps. Firstly, the named commit is cherry-picked. Secondly, the commit created in the first step is amended using an unchanged index to edit the log message. The pre-commit hook is meant to verify the changes introduced by a commit (for instance, catching inserted trailing white space). Since the committed tree is not changed between the two steps and we do not verify rebased patches, do not execute the pre-commit hook in the second step. Specify the git-commit option `--no-pre-commit` to disable the pre-commit hook when editing the log message. The commit-msg hook will still be executed to verify the edited commit log message. As before, if the hook finds the new log message ill-formatted, the rebase will be interrupted with the unchanged commit replayed and the new log message in `$GIT_DIR/COMMIT_EDITMSG`. Add tests. Signed-off-by: Fabian Ruch <bafain@xxxxxxxxx> --- git-rebase--interactive.sh | 2 +- t/t3404-rebase-interactive.sh | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh index 54c4614..570c4e9 100644 --- a/git-rebase--interactive.sh +++ b/git-rebase--interactive.sh @@ -504,7 +504,7 @@ do_next () { mark_action_done do_pick $sha1 "$rest" - output git commit --allow-empty --amend --no-post-rewrite ${gpg_sign_opt:+"$gpg_sign_opt"} || { + output git commit --allow-empty --amend --no-post-rewrite --no-pre-commit ${gpg_sign_opt:+"$gpg_sign_opt"} || { warn "Could not amend commit after successfully picking $sha1... $rest" exit_with_patch $sha1 1 } diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index abb829e..ecdab11 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -683,6 +683,13 @@ test_expect_success 'setup failing pre-commit' ' test_commit --no-verify pre-commit-violated-3 ' +test_expect_success 'reword a commit violating pre-commit' ' + git checkout -b reword-violating-pre-commit violating-pre-commit && + test_when_finished reset_rebase && + set_fake_editor && + env FAKE_LINES="reword 1" git rebase -i master +' + test_expect_success 'squash commits violating pre-commit' ' git checkout -b squash-violating-pre-commit violating-pre-commit && test_when_finished reset_rebase && @@ -726,6 +733,13 @@ test_expect_success 'rebase a commit violating commit-msg' ' FAKE_LINES="1" git rebase -i master ' +test_expect_success 'reword a commit violating commit-msg' ' + git checkout -b reword-violating-commit-msg violating-commit-msg && + test_when_finished reset_rebase && + set_fake_editor && + test_must_fail env FAKE_LINES="reword 1" git rebase -i master +' + test_expect_success 'squash commits violating commit-msg' ' git checkout -b squash-violating-commit-msg violating-commit-msg && set_fake_editor && -- 2.0.1 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html