]> git.ipfire.org Git - thirdparty/git.git/blame - t/t0033-safe-directory.sh
config.c: NULL check when reading protected config
[thirdparty/git.git] / t / t0033-safe-directory.sh
CommitLineData
e47363e5
DS
1#!/bin/sh
2
3test_description='verify safe.directory checks'
4
5. ./test-lib.sh
6
7GIT_TEST_ASSUME_DIFFERENT_OWNER=1
8export GIT_TEST_ASSUME_DIFFERENT_OWNER
9
10expect_rejected_dir () {
11 test_must_fail git status 2>err &&
69ab3309 12 grep "dubious ownership" err
e47363e5
DS
13}
14
15test_expect_success 'safe.directory is not set' '
16 expect_rejected_dir
17'
18
6061601d
GC
19test_expect_success 'safe.directory on the command line' '
20 git -c safe.directory="$(pwd)" status
424f315d
SG
21'
22
6061601d
GC
23test_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
30test_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
35test_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
43test_expect_success 'safe.directory does not match' '
44 git config --global safe.directory bogus &&
45 expect_rejected_dir
46'
47
bb50ec3c
MV
48test_expect_success 'path exist as different key' '
49 git config --global foo.bar "$(pwd)" &&
50 expect_rejected_dir
51'
52
e47363e5
DS
53test_expect_success 'safe.directory matches' '
54 git config --global --add safe.directory "$(pwd)" &&
55 git status
56'
57
58test_expect_success 'safe.directory matches, but is reset' '
59 git config --global --add safe.directory "" &&
60 expect_rejected_dir
61'
62
0f85c4a3
DS
63test_expect_success 'safe.directory=*' '
64 git config --global --add safe.directory "*" &&
65 git status
66'
67
68test_expect_success 'safe.directory=*, but is reset' '
69 git config --global --add safe.directory "" &&
70 expect_rejected_dir
71'
72
e47363e5 73test_done