t0033-safe-directory: check when 'safe.directory' is ignored
According to the documentation 'safe.directory' "is only respected when specified in a system or global config, not when it is specified in a repository config or via the command line option -c safe.directory=<path>". Add tests to check that 'safe.directory' in the repository config or on the command line is indeed ignored. Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
SZEDER Gábor committed
Apr 27, 2022 at 19:06 UTC
424f315d9f15338ee950f343e01becd6f087121b
1 file changed
+13
t/t0033-safe-directory.sh
+13
@@ -16,6 +16,19 @@ test_expect_success 'safe.directory is not set' '
16
expect_rejected_dir
17
'
18
19
+test_expect_success 'ignoring safe.directory on the command line' '
20
+ test_must_fail git -c safe.directory="$(pwd)" status 2>err &&
21
+ grep "unsafe repository" err
22
+'
23
+
24
+test_expect_success 'ignoring safe.directory in repo config' '
25
+ (
26
+ unset GIT_TEST_ASSUME_DIFFERENT_OWNER &&
27
+ git config safe.directory "$(pwd)"
28
+ ) &&
29
+ expect_rejected_dir
30
+'
31
+
32
test_expect_success 'safe.directory does not match' '
33
git config --global safe.directory bogus &&
34
expect_rejected_dir