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>
David Aguilar committed
Jun 2, 2011 at 02:26 UTC
c35ec8c901a2391c4652ab1acdff04c9d67b1543
1 file changed
+33
t/t7503-pre-commit-hook.sh
+33
@@ -84,5 +84,38 @@ test_expect_success POSIXPERM '--no-verify with non-executable hook' '
84
git commit --no-verify -m "more content"
85
86
'
87
+chmod +x "$HOOK"
88
+
89
+# a hook that checks $GIT_PREFIX and succeeds inside the
90
+# success/ subdirectory only
91
+cat > "$HOOK" <<EOF
92
+#!/bin/sh
93
+test \$GIT_PREFIX = success/
94
+EOF
95
+
96
+test_expect_success 'with hook requiring GIT_PREFIX' '
97
+
98
+ echo "more content" >> file &&
99
+ git add file &&
100
+ mkdir success &&
101
+ (
102
+ cd success &&
103
+ git commit -m "hook requires GIT_PREFIX = success/"
104
+ ) &&
105
+ rmdir success
106
+'
107
+
108
+test_expect_success 'with failing hook requiring GIT_PREFIX' '
109
+
110
+ echo "more content" >> file &&
111
+ git add file &&
112
+ mkdir fail &&
113
+ (
114
+ cd fail &&
115
+ test_must_fail git commit -m "hook must fail"
116
+ ) &&
117
+ rmdir fail &&
118
+ git checkout -- file
119
+'
120
121
test_done