summaryrefslogtreecommitdiff
path: root/t/t7503-pre-commit-hook.sh
diff options
context:
space:
mode:
authorDavid Aguilar <davvid@gmail.com>2011-06-02 09:26:25 (GMT)
committerJunio C Hamano <gitster@pobox.com>2011-06-02 16:14:44 (GMT)
commitc35ec8c901a2391c4652ab1acdff04c9d67b1543 (patch)
tree69e830a7c8f85e01367a486cebaac933ae9b2fa2 /t/t7503-pre-commit-hook.sh
parentf9ad901fd31991837c9648bbee8ac18b39aa0891 (diff)
downloadgit-c35ec8c901a2391c4652ab1acdff04c9d67b1543.zip
git-c35ec8c901a2391c4652ab1acdff04c9d67b1543.tar.gz
git-c35ec8c901a2391c4652ab1acdff04c9d67b1543.tar.bz2
t/t7503-pre-commit-hook.sh: Add GIT_PREFIX tests
Ensure that the pre-commit hook has access to GIT_PREFIX. Signed-off-by: David Aguilar <davvid@gmail.com> 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.sh33
1 files changed, 33 insertions, 0 deletions
diff --git a/t/t7503-pre-commit-hook.sh b/t/t7503-pre-commit-hook.sh
index 8528f64..ee7f0cd 100755
--- a/t/t7503-pre-commit-hook.sh
+++ b/t/t7503-pre-commit-hook.sh
@@ -84,5 +84,38 @@ test_expect_success POSIXPERM '--no-verify with non-executable hook' '
git commit --no-verify -m "more content"
'
+chmod +x "$HOOK"
+
+# a hook that checks $GIT_PREFIX and succeeds inside the
+# success/ subdirectory only
+cat > "$HOOK" <<EOF
+#!/bin/sh
+test \$GIT_PREFIX = success/
+EOF
+
+test_expect_success 'with hook requiring GIT_PREFIX' '
+
+ echo "more content" >> file &&
+ git add file &&
+ mkdir success &&
+ (
+ cd success &&
+ git commit -m "hook requires GIT_PREFIX = success/"
+ ) &&
+ rmdir success
+'
+
+test_expect_success 'with failing hook requiring GIT_PREFIX' '
+
+ echo "more content" >> file &&
+ git add file &&
+ mkdir fail &&
+ (
+ cd fail &&
+ test_must_fail git commit -m "hook must fail"
+ ) &&
+ rmdir fail &&
+ git checkout -- file
+'
test_done