summaryrefslogtreecommitdiff
path: root/t/t0033-safe-directory.sh
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2022-04-13 22:21:28 (GMT)
committerJunio C Hamano <gitster@pobox.com>2022-04-13 22:21:28 (GMT)
commit1f65dd6ae635f77c588ac432cad1a299723d00d6 (patch)
treed276b872a065585c0c85c1f4c2d0d544e46fd7ba /t/t0033-safe-directory.sh
parent87ed4fc046840706138d46e0033a009e74c3887a (diff)
parent15304344342b7c888f732d28f908890d874bcb0c (diff)
downloadgit-5e18c82bb9ac28d482413466150f08a7d49230e9.zip
git-5e18c82bb9ac28d482413466150f08a7d49230e9.tar.gz
git-5e18c82bb9ac28d482413466150f08a7d49230e9.tar.bz2
Git 2.33.3v2.33.3
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t0033-safe-directory.sh')
-rwxr-xr-xt/t0033-safe-directory.sh49
1 files changed, 49 insertions, 0 deletions
diff --git a/t/t0033-safe-directory.sh b/t/t0033-safe-directory.sh
new file mode 100755
index 0000000..239d93f
--- /dev/null
+++ b/t/t0033-safe-directory.sh
@@ -0,0 +1,49 @@
+#!/bin/sh
+
+test_description='verify safe.directory checks'
+
+. ./test-lib.sh
+
+GIT_TEST_ASSUME_DIFFERENT_OWNER=1
+export GIT_TEST_ASSUME_DIFFERENT_OWNER
+
+expect_rejected_dir () {
+ test_must_fail git status 2>err &&
+ grep "safe.directory" err
+}
+
+test_expect_success 'safe.directory is not set' '
+ expect_rejected_dir
+'
+
+test_expect_success 'safe.directory does not match' '
+ git config --global safe.directory bogus &&
+ expect_rejected_dir
+'
+
+test_expect_success 'path exist as different key' '
+ git config --global foo.bar "$(pwd)" &&
+ expect_rejected_dir
+'
+
+test_expect_success 'safe.directory matches' '
+ git config --global --add safe.directory "$(pwd)" &&
+ git status
+'
+
+test_expect_success 'safe.directory matches, but is reset' '
+ git config --global --add safe.directory "" &&
+ expect_rejected_dir
+'
+
+test_expect_success 'safe.directory=*' '
+ git config --global --add safe.directory "*" &&
+ git status
+'
+
+test_expect_success 'safe.directory=*, but is reset' '
+ git config --global --add safe.directory "" &&
+ expect_rejected_dir
+'
+
+test_done