]>
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 | ||
6061601d GC |
19 | test_expect_success 'safe.directory on the command line' ' |
20 | git -c safe.directory="$(pwd)" status | |
424f315d SG |
21 | ' |
22 | ||
6061601d GC |
23 | test_expect_success 'safe.directory in the environment' ' |
24 | env GIT_CONFIG_COUNT=1 \ | |
25 | GIT_CONFIG_KEY_0="safe.directory" \ | |
26 | GIT_CONFIG_VALUE_0="$(pwd)" \ | |
27 | git status | |
756d1592 SG |
28 | ' |
29 | ||
6061601d GC |
30 | test_expect_success 'safe.directory in GIT_CONFIG_PARAMETERS' ' |
31 | env GIT_CONFIG_PARAMETERS="${SQ}safe.directory${SQ}=${SQ}$(pwd)${SQ}" \ | |
32 | git status | |
756d1592 SG |
33 | ' |
34 | ||
424f315d SG |
35 | test_expect_success 'ignoring safe.directory in repo config' ' |
36 | ( | |
37 | unset GIT_TEST_ASSUME_DIFFERENT_OWNER && | |
38 | git config safe.directory "$(pwd)" | |
39 | ) && | |
40 | expect_rejected_dir | |
41 | ' | |
42 | ||
e47363e5 DS |
43 | test_expect_success 'safe.directory does not match' ' |
44 | git config --global safe.directory bogus && | |
45 | expect_rejected_dir | |
46 | ' | |
47 | ||
bb50ec3c MV |
48 | test_expect_success 'path exist as different key' ' |
49 | git config --global foo.bar "$(pwd)" && | |
50 | expect_rejected_dir | |
51 | ' | |
52 | ||
e47363e5 DS |
53 | test_expect_success 'safe.directory matches' ' |
54 | git config --global --add safe.directory "$(pwd)" && | |
55 | git status | |
56 | ' | |
57 | ||
58 | test_expect_success 'safe.directory matches, but is reset' ' | |
59 | git config --global --add safe.directory "" && | |
60 | expect_rejected_dir | |
61 | ' | |
62 | ||
0f85c4a3 DS |
63 | test_expect_success 'safe.directory=*' ' |
64 | git config --global --add safe.directory "*" && | |
65 | git status | |
66 | ' | |
67 | ||
68 | test_expect_success 'safe.directory=*, but is reset' ' | |
69 | git config --global --add safe.directory "" && | |
70 | expect_rejected_dir | |
71 | ' | |
72 | ||
e47363e5 | 73 | test_done |