git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] t/t7503-pre-commit-hook.sh: Add GIT_PREFIX tests

From
David Aguilar <davvid@gmail.com>
Date
Jun 2, 2011, 09:26 UTC
Message-ID
<1307006785-17529-1-git-send-email-davvid@gmail.com>
Ensure that the pre-commit hook has access to GIT_PREFIX.
Signed-off-by: David Aguilar <davvid@gmail.com>
---
Requires da/git-prefix-everywhere currently in next
 t/t7503-pre-commit-hook.sh |   33 +++++++++++++++++++++++++++++++++
 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
-- 
1.7.6.rc0.253.ga984a1
Message 1 of 1 in “t/t7503-pre-commit-hook.sh: Add GIT_PREFIX tests”
  1. t/t7503-pre-commit-hook.sh: Add GIT_PREFIX testsDavid Aguilar, Jun 2, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.