Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2022-05-21 01:26:52 +0300
committerJunio C Hamano <gitster@pobox.com>2022-05-21 01:26:52 +0300
commit1256a25ecd5df8fb418a537d856bf442da984c17 (patch)
tree60b62f20d3e6fae8d36267bc7655797fe9c4a1c7 /t
parent277cf0bc36094f6dc4297d8c9cef79df045b735d (diff)
parent756d15923bf6806f94484054873e284728a89c4b (diff)
Merge branch 'sg/safe-directory-tests-and-docs'
New tests for the safe.directory mechanism. * sg/safe-directory-tests-and-docs: safe.directory: document and check that it's ignored in the environment t0033-safe-directory: check when 'safe.directory' is ignored t0033-safe-directory: check the error message without matching the trash dir
Diffstat (limited to 't')
-rwxr-xr-xt/t0033-safe-directory.sh30
1 files changed, 29 insertions, 1 deletions
diff --git a/t/t0033-safe-directory.sh b/t/t0033-safe-directory.sh
index 239d93f4d2..238b25f91a 100755
--- a/t/t0033-safe-directory.sh
+++ b/t/t0033-safe-directory.sh
@@ -9,13 +9,41 @@ export GIT_TEST_ASSUME_DIFFERENT_OWNER
expect_rejected_dir () {
test_must_fail git status 2>err &&
- grep "safe.directory" err
+ grep "unsafe repository" err
}
test_expect_success 'safe.directory is not set' '
expect_rejected_dir
'
+test_expect_success 'ignoring safe.directory on the command line' '
+ test_must_fail git -c safe.directory="$(pwd)" status 2>err &&
+ grep "unsafe repository" err
+'
+
+test_expect_success 'ignoring safe.directory in the environment' '
+ test_must_fail env GIT_CONFIG_COUNT=1 \
+ GIT_CONFIG_KEY_0="safe.directory" \
+ GIT_CONFIG_VALUE_0="$(pwd)" \
+ git status 2>err &&
+ grep "unsafe repository" err
+'
+
+test_expect_success 'ignoring safe.directory in GIT_CONFIG_PARAMETERS' '
+ test_must_fail env \
+ GIT_CONFIG_PARAMETERS="${SQ}safe.directory${SQ}=${SQ}$(pwd)${SQ}" \
+ git status 2>err &&
+ grep "unsafe repository" err
+'
+
+test_expect_success 'ignoring safe.directory in repo config' '
+ (
+ unset GIT_TEST_ASSUME_DIFFERENT_OWNER &&
+ git config safe.directory "$(pwd)"
+ ) &&
+ expect_rejected_dir
+'
+
test_expect_success 'safe.directory does not match' '
git config --global safe.directory bogus &&
expect_rejected_dir