When "--author" option is used to lie the authorship to "git commit" command, hooks should learn the author name and email just like when GIT_AUTHOR_NAME and GIT_AUTHOR_EMAIL environment variables are used to lie the authorship. Test this. Signed-off-by: Junio C Hamano <gitster@xxxxxxxxx> --- * This is the first one of two patches that are shread by two approaches. What it tests should be obvious---the current code fails with the last piece that use --author. t/t7503-pre-commit-hook.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/t/t7503-pre-commit-hook.sh b/t/t7503-pre-commit-hook.sh index ee7f0cd..fc6de5b 100755 --- a/t/t7503-pre-commit-hook.sh +++ b/t/t7503-pre-commit-hook.sh @@ -118,4 +118,22 @@ test_expect_success 'with failing hook requiring GIT_PREFIX' ' git checkout -- file ' +test_expect_failure 'check the author in hook' ' + cat >"$HOOK" <<-\EOF && + test "$GIT_AUTHOR_NAME" = "New Author" && + test "$GIT_AUTHOR_EMAIL" = "newauthor@xxxxxxxxxxx" + EOF + test_must_fail git commit --allow-empty -m "by a.u.thor" && + ( + GIT_AUTHOR_NAME="New Author" && + GIT_AUTHOR_EMAIL="newauthor@xxxxxxxxxxx" && + export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL && + git commit --allow-empty -m "by new.author via env" && + git show -s + ) && + git commit --author="New Author <newauthor@xxxxxxxxxxx>" \ + --allow-empty -m "by new.author via command line" && + git show -s +' + test_done -- 1.7.10.rc0.33.g8866af -- 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