]> git.ipfire.org Git - thirdparty/git.git/blame - t/t0033-safe-directory.sh
The third batch
[thirdparty/git.git] / t / t0033-safe-directory.sh
CommitLineData
e47363e5
DS
1#!/bin/sh
2
3test_description='verify safe.directory checks'
4
3e3b9321 5TEST_PASSES_SANITIZE_LEAK=true
e47363e5
DS
6. ./test-lib.sh
7
8GIT_TEST_ASSUME_DIFFERENT_OWNER=1
9export GIT_TEST_ASSUME_DIFFERENT_OWNER
10
11expect_rejected_dir () {
12 test_must_fail git status 2>err &&
69ab3309 13 grep "dubious ownership" err
e47363e5
DS
14}
15
16test_expect_success 'safe.directory is not set' '
17 expect_rejected_dir
18'
19
6061601d
GC
20test_expect_success 'safe.directory on the command line' '
21 git -c safe.directory="$(pwd)" status
424f315d
SG
22'
23
6061601d
GC
24test_expect_success 'safe.directory in the environment' '
25 env GIT_CONFIG_COUNT=1 \
26 GIT_CONFIG_KEY_0="safe.directory" \
27 GIT_CONFIG_VALUE_0="$(pwd)" \
28 git status
756d1592
SG
29'
30
6061601d
GC
31test_expect_success 'safe.directory in GIT_CONFIG_PARAMETERS' '
32 env GIT_CONFIG_PARAMETERS="${SQ}safe.directory${SQ}=${SQ}$(pwd)${SQ}" \
33 git status
756d1592
SG
34'
35
424f315d
SG
36test_expect_success 'ignoring safe.directory in repo config' '
37 (
38 unset GIT_TEST_ASSUME_DIFFERENT_OWNER &&
39 git config safe.directory "$(pwd)"
40 ) &&
41 expect_rejected_dir
42'
43
e47363e5
DS
44test_expect_success 'safe.directory does not match' '
45 git config --global safe.directory bogus &&
46 expect_rejected_dir
47'
48
bb50ec3c
MV
49test_expect_success 'path exist as different key' '
50 git config --global foo.bar "$(pwd)" &&
51 expect_rejected_dir
52'
53
e47363e5
DS
54test_expect_success 'safe.directory matches' '
55 git config --global --add safe.directory "$(pwd)" &&
56 git status
57'
58
59test_expect_success 'safe.directory matches, but is reset' '
60 git config --global --add safe.directory "" &&
61 expect_rejected_dir
62'
63
0f85c4a3
DS
64test_expect_success 'safe.directory=*' '
65 git config --global --add safe.directory "*" &&
66 git status
67'
68
69test_expect_success 'safe.directory=*, but is reset' '
70 git config --global --add safe.directory "" &&
71 expect_rejected_dir
72'
73
ecec57b3
GC
74test_expect_success 'safe.directory in included file' '
75 cat >gitconfig-include <<-EOF &&
76 [safe]
77 directory = "$(pwd)"
78 EOF
79 git config --global --add include.path "$(pwd)/gitconfig-include" &&
80 git status
81'
82
e47363e5 83test_done