summaryrefslogtreecommitdiff
path: root/t/t0033-safe-directory.sh
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2022-04-13 22:21:34 (GMT)
committerJunio C Hamano <gitster@pobox.com>2022-04-13 22:21:34 (GMT)
commitd516b2db0af2221bd6b13e7347abdcb5830b2829 (patch)
tree5ce8656672734b2dabab1a10747ce6674d139ac5 /t/t0033-safe-directory.sh
parent53ef17d3ee0f7fcb151f428ee3bd736b8046825f (diff)
parent2f0dde7852b7866bb044926f73334ff3fc30654b (diff)
downloadgit-2dcfc3c7b3e36ce197c416921c23973a924a9a64.zip
git-2dcfc3c7b3e36ce197c416921c23973a924a9a64.tar.gz
git-2dcfc3c7b3e36ce197c416921c23973a924a9a64.tar.bz2
Git 2.35.3v2.35.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