summaryrefslogtreecommitdiff
path: root/t/t7503-pre-commit-hook.sh
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2012-03-11 10:51:32 (GMT)
committerJunio C Hamano <gitster@pobox.com>2012-03-11 21:06:08 (GMT)
commit04861982e553289c923b2f9ef829ef33206c9bc4 (patch)
treeea9533f3430d6011fc22655ade6a74173e78cf4b /t/t7503-pre-commit-hook.sh
parent4b340cfab9c7a18e39bc531d6a6ffaffdf95f62d (diff)
downloadgit-04861982e553289c923b2f9ef829ef33206c9bc4.zip
git-04861982e553289c923b2f9ef829ef33206c9bc4.tar.gz
git-04861982e553289c923b2f9ef829ef33206c9bc4.tar.bz2
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>
Diffstat (limited to 't/t7503-pre-commit-hook.sh')
-rwxr-xr-xt/t7503-pre-commit-hook.sh18
1 files changed, 18 insertions, 0 deletions
diff --git a/t/t7503-pre-commit-hook.sh b/t/t7503-pre-commit-hook.sh
index ee7f0cd..aa294ea 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' '
+ write_script "$HOOK" <<-\EOF &&
+ test "$GIT_AUTHOR_NAME" = "New Author" &&
+ test "$GIT_AUTHOR_EMAIL" = "newauthor@example.com"
+ EOF
+ test_must_fail git commit --allow-empty -m "by a.u.thor" &&
+ (
+ GIT_AUTHOR_NAME="New Author" &&
+ GIT_AUTHOR_EMAIL="newauthor@example.com" &&
+ 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@example.com>" \
+ --allow-empty -m "by new.author via command line" &&
+ git show -s
+'
+
test_done