@@ -38,6 +38,13 @@ test_expect_success 'read with --get: xdg file exists and ~/.gitconfig doesn'\''
38
38
test_cmp expected actual
39
39
'
40
40
41
+ test_expect_success ' "$XDG_CONFIG_HOME overrides $HOME/.config/git' '
42
+ mkdir -p "$HOME"/xdg/git &&
43
+ echo "[user]name = in_xdg" >"$HOME"/xdg/git/config &&
44
+ echo in_xdg >expected &&
45
+ XDG_CONFIG_HOME="$HOME"/xdg git config --get-all user.name >actual &&
46
+ test_cmp expected actual
47
+ '
41
48
42
49
test_expect_success ' read with --get: xdg file exists and ~/.gitconfig exists' '
43
50
>.gitconfig &&
@@ -80,6 +87,17 @@ test_expect_success 'Exclusion of a file in the XDG ignore file' '
80
87
test_must_fail git add to_be_excluded
81
88
'
82
89
90
+ test_expect_success ' $XDG_CONFIG_HOME overrides $HOME/.config/git/ignore' '
91
+ mkdir -p "$HOME"/xdg/git &&
92
+ echo content >excluded_by_xdg_only &&
93
+ echo excluded_by_xdg_only >"$HOME"/xdg/git/ignore &&
94
+ test_when_finished "git read-tree --empty" &&
95
+ (XDG_CONFIG_HOME="$HOME/xdg" &&
96
+ export XDG_CONFIG_HOME &&
97
+ git add to_be_excluded &&
98
+ test_must_fail git add excluded_by_xdg_only
99
+ )
100
+ '
83
101
84
102
test_expect_success ' Exclusion in both XDG and local ignore files' '
85
103
echo to_be_excluded >.gitignore &&
@@ -120,6 +138,14 @@ test_expect_success 'Checking XDG attributes when HOME is unset' '
120
138
test_cmp expected actual
121
139
'
122
140
141
+ test_expect_success ' $XDG_CONFIG_HOME overrides $HOME/.config/git/attributes' '
142
+ mkdir -p "$HOME"/xdg/git &&
143
+ echo "f attr_f=xdg" >"$HOME"/xdg/git/attributes &&
144
+ echo "f: attr_f: xdg" >expected &&
145
+ XDG_CONFIG_HOME="$HOME/xdg" git check-attr -a f >actual &&
146
+ test_cmp expected actual
147
+ '
148
+
123
149
test_expect_success ' Checking attributes in both XDG and local attributes files' '
124
150
echo "f -attr_f" >.gitattributes &&
125
151
echo "f: attr_f: unset" >expected &&
0 commit comments