From: David Aguilar Date: Thu, 2 Jun 2011 09:26:25 +0000 (-0700) Subject: t/t7503-pre-commit-hook.sh: Add GIT_PREFIX tests X-Git-Tag: v1.7.7-rc0~114^2 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=c35ec8c901a2391c4652ab1acdff04c9d67b1543;p=git.git 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 Signed-off-by: Junio C Hamano --- diff --git a/t/t7503-pre-commit-hook.sh b/t/t7503-pre-commit-hook.sh index 8528f64c8..ee7f0cd45 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" <> 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