Skip to content

Commit 22ae029

Browse files
peffgitster
authored andcommitted
t1306: check that XDG_CONFIG_HOME works
This should override $HOME/.config, but we never actually tested it. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6283a37 commit 22ae029

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

t/t1306-xdg-files.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

4249
test_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

84102
test_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+
123149
test_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

Comments
 (0)