@@ -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 &&
@@ -95,6 +113,13 @@ test_expect_success 'Exclusion in a non-XDG global ignore file' '
95
113
test_must_fail git add to_be_excluded
96
114
'
97
115
116
+ test_expect_success ' Checking XDG ignore file when HOME is unset' '
117
+ >expected &&
118
+ (sane_unset HOME &&
119
+ git config --unset core.excludesfile &&
120
+ git ls-files --exclude-standard --ignored >actual) &&
121
+ test_cmp expected actual
122
+ '
98
123
99
124
test_expect_success ' Checking attributes in the XDG attributes file' '
100
125
echo foo >f &&
@@ -106,6 +131,20 @@ test_expect_success 'Checking attributes in the XDG attributes file' '
106
131
test_cmp expected actual
107
132
'
108
133
134
+ test_expect_success ' Checking XDG attributes when HOME is unset' '
135
+ >expected &&
136
+ (sane_unset HOME &&
137
+ git check-attr -a f >actual) &&
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
+ '
109
148
110
149
test_expect_success ' Checking attributes in both XDG and local attributes files' '
111
150
echo "f -attr_f" >.gitattributes &&
0 commit comments