t7503: does pre-commit-hook learn authorship?

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@pobox.com>

Junio C Hamano committed Mar 11, 2012 at 03:51 UTC 04861982e553289c923b2f9ef829ef33206c9bc4
1 file changed +18
t/t7503-pre-commit-hook.sh
+18
@@ -118,4 +118,22 @@ test_expect_success 'with failing hook requiring GIT_PREFIX' '
118 git checkout -- file
119 '
120
121 +test_expect_failure 'check the author in hook' '
122 + write_script "$HOOK" <<-\EOF &&
123 + test "$GIT_AUTHOR_NAME" = "New Author" &&
124 + test "$GIT_AUTHOR_EMAIL" = "newauthor@example.com"
125 + EOF
126 + test_must_fail git commit --allow-empty -m "by a.u.thor" &&
127 + (
128 + GIT_AUTHOR_NAME="New Author" &&
129 + GIT_AUTHOR_EMAIL="newauthor@example.com" &&
130 + export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL &&
131 + git commit --allow-empty -m "by new.author via env" &&
132 + git show -s
133 + ) &&
134 + git commit --author="New Author <newauthor@example.com>" \
135 + --allow-empty -m "by new.author via command line" &&
136 + git show -s
137 +'
138 +
139 test_done