aboutsummaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-06-29 17:09:27 -0700
committerJunio C Hamano <gitster@pobox.com>2011-06-29 17:09:27 -0700
commit4ed54610e5ca8fdc34dcf8729f6416599d1bc39e (patch)
tree3eca1184326848950e0a35938c7ca7032e45a6a1 /t
parent55ac692661f7b850bb0160de18fa9868d24dbe17 (diff)
parentc35ec8c901a2391c4652ab1acdff04c9d67b1543 (diff)
downloadgit-4ed54610e5ca8fdc34dcf8729f6416599d1bc39e.tar.gz
git-4ed54610e5ca8fdc34dcf8729f6416599d1bc39e.tar.xz
Merge branch 'da/git-prefix-everywhere' into next
* da/git-prefix-everywhere: t/t7503-pre-commit-hook.sh: Add GIT_PREFIX tests git-mergetool--lib: Make vimdiff retain the current directory git: Remove handling for GIT_PREFIX setup: Provide GIT_PREFIX to built-ins
Diffstat (limited to 't')
-rwxr-xr-xt/t1020-subdirectory.sh16
-rwxr-xr-xt/t7503-pre-commit-hook.sh33
2 files changed, 49 insertions, 0 deletions
diff --git a/t/t1020-subdirectory.sh b/t/t1020-subdirectory.sh
index f6a44c9ee..865b8ed26 100755
--- a/t/t1020-subdirectory.sh
+++ b/t/t1020-subdirectory.sh
@@ -140,6 +140,22 @@ test_expect_success 'GIT_PREFIX for !alias' '
test_cmp expect actual
'
+test_expect_success 'GIT_PREFIX for built-ins' '
+ # Use GIT_EXTERNAL_DIFF to test that the "diff" built-in
+ # receives the GIT_PREFIX variable.
+ printf "dir/" >expect &&
+ printf "#!/bin/sh\n" >diff &&
+ printf "printf \"\$GIT_PREFIX\"" >>diff &&
+ chmod +x diff &&
+ (
+ cd dir &&
+ printf "change" >two &&
+ env GIT_EXTERNAL_DIFF=./diff git diff >../actual
+ git checkout -- two
+ ) &&
+ test_cmp expect actual
+'
+
test_expect_success 'no file/rev ambiguity check inside .git' '
git commit -a -m 1 &&
(
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" <<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