@@ -38,6 +38,13 @@ test_expect_success 'read with --get: xdg file exists and ~/.gitconfig doesn'\''
3838 test_cmp expected actual
3939'
4040
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+ '
4148
4249test_expect_success ' read with --get: xdg file exists and ~/.gitconfig exists' '
4350 >.gitconfig &&
@@ -80,6 +87,17 @@ test_expect_success 'Exclusion of a file in the XDG ignore file' '
8087 test_must_fail git add to_be_excluded
8188'
8289
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+ '
83101
84102test_expect_success ' Exclusion in both XDG and local ignore files' '
85103 echo to_be_excluded >.gitignore &&
@@ -120,6 +138,14 @@ test_expect_success 'Checking XDG attributes when HOME is unset' '
120138 test_cmp expected actual
121139'
122140
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+
123149test_expect_success ' Checking attributes in both XDG and local attributes files' '
124150 echo "f -attr_f" >.gitattributes &&
125151 echo "f: attr_f: unset" >expected &&
0 commit comments