t1306: check that XDG_CONFIG_HOME works

This should override $HOME/.config, but we never actually tested it. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Jul 24, 2012 at 08:27 UTC 22ae029a1e0631570a2db5d030e5755f9be96eee
1 file changed +26
t/t1306-xdg-files.sh
+26
@@ -38,6 +38,13 @@ test_expect_success 'read with --get: xdg file exists and ~/.gitconfig doesn'\''
38 test_cmp expected actual
39 '
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 +'
48
49 test_expect_success 'read with --get: xdg file exists and ~/.gitconfig exists' '
50 >.gitconfig &&
@@ -80,6 +87,17 @@ test_expect_success 'Exclusion of a file in the XDG ignore file' '
87 test_must_fail git add to_be_excluded
88 '
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 +'
101
102 test_expect_success 'Exclusion in both XDG and local ignore files' '
103 echo to_be_excluded >.gitignore &&
@@ -120,6 +138,14 @@ test_expect_success 'Checking XDG attributes when HOME is unset' '
138 test_cmp expected actual
139 '
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 +
149 test_expect_success 'Checking attributes in both XDG and local attributes files' '
150 echo "f -attr_f" >.gitattributes &&
151 echo "f: attr_f: unset" >expected &&