]> git.ipfire.org Git - thirdparty/git.git/blob - t/t0033-safe-directory.sh
clone: allow "--bare" with "-o"
[thirdparty/git.git] / t / t0033-safe-directory.sh
1 #!/bin/sh
2
3 test_description='verify safe.directory checks'
4
5 . ./test-lib.sh
6
7 GIT_TEST_ASSUME_DIFFERENT_OWNER=1
8 export GIT_TEST_ASSUME_DIFFERENT_OWNER
9
10 expect_rejected_dir () {
11 test_must_fail git status 2>err &&
12 grep "dubious ownership" err
13 }
14
15 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 "dubious ownership" err
22 '
23
24 test_expect_success 'ignoring safe.directory in the environment' '
25 test_must_fail env GIT_CONFIG_COUNT=1 \
26 GIT_CONFIG_KEY_0="safe.directory" \
27 GIT_CONFIG_VALUE_0="$(pwd)" \
28 git status 2>err &&
29 grep "dubious ownership" err
30 '
31
32 test_expect_success 'ignoring safe.directory in GIT_CONFIG_PARAMETERS' '
33 test_must_fail env \
34 GIT_CONFIG_PARAMETERS="${SQ}safe.directory${SQ}=${SQ}$(pwd)${SQ}" \
35 git status 2>err &&
36 grep "dubious ownership" err
37 '
38
39 test_expect_success 'ignoring safe.directory in repo config' '
40 (
41 unset GIT_TEST_ASSUME_DIFFERENT_OWNER &&
42 git config safe.directory "$(pwd)"
43 ) &&
44 expect_rejected_dir
45 '
46
47 test_expect_success 'safe.directory does not match' '
48 git config --global safe.directory bogus &&
49 expect_rejected_dir
50 '
51
52 test_expect_success 'path exist as different key' '
53 git config --global foo.bar "$(pwd)" &&
54 expect_rejected_dir
55 '
56
57 test_expect_success 'safe.directory matches' '
58 git config --global --add safe.directory "$(pwd)" &&
59 git status
60 '
61
62 test_expect_success 'safe.directory matches, but is reset' '
63 git config --global --add safe.directory "" &&
64 expect_rejected_dir
65 '
66
67 test_expect_success 'safe.directory=*' '
68 git config --global --add safe.directory "*" &&
69 git status
70 '
71
72 test_expect_success 'safe.directory=*, but is reset' '
73 git config --global --add safe.directory "" &&
74 expect_rejected_dir
75 '
76
77 test_done