]>
Commit | Line | Data |
---|---|---|
e47363e5 DS |
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 && | |
69ab3309 | 12 | grep "dubious ownership" err |
e47363e5 DS |
13 | } |
14 | ||
15 | test_expect_success 'safe.directory is not set' ' | |
16 | expect_rejected_dir | |
17 | ' | |
18 | ||
424f315d SG |
19 | test_expect_success 'ignoring safe.directory on the command line' ' |
20 | test_must_fail git -c safe.directory="$(pwd)" status 2>err && | |
69ab3309 | 21 | grep "dubious ownership" err |
424f315d SG |
22 | ' |
23 | ||
756d1592 SG |
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 && | |
69ab3309 | 29 | grep "dubious ownership" err |
756d1592 SG |
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 && | |
69ab3309 | 36 | grep "dubious ownership" err |
756d1592 SG |
37 | ' |
38 | ||
424f315d SG |
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 | ||
e47363e5 DS |
47 | test_expect_success 'safe.directory does not match' ' |
48 | git config --global safe.directory bogus && | |
49 | expect_rejected_dir | |
50 | ' | |
51 | ||
bb50ec3c MV |
52 | test_expect_success 'path exist as different key' ' |
53 | git config --global foo.bar "$(pwd)" && | |
54 | expect_rejected_dir | |
55 | ' | |
56 | ||
e47363e5 DS |
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 | ||
0f85c4a3 DS |
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 | ||
e47363e5 | 77 | test_done |