182
)
183
'
184
185
+test_expect_success 'GIT_CONFIG_SYSTEM points to the correct location' '
186
+ TRASHDIR="$(test-tool path-utils normalize_path_copy "$(pwd)")" &&
187
+ test_must_fail env GIT_CONFIG_NOSYSTEM=1 git var GIT_CONFIG_SYSTEM &&
188
+ (
189
+ sane_unset GIT_CONFIG_NOSYSTEM &&
190
+ systempath=$(git var GIT_CONFIG_SYSTEM) &&
191
+ test "$systempath" != "" &&
192
+ systempath=$(GIT_CONFIG_SYSTEM=/dev/null git var GIT_CONFIG_SYSTEM) &&
193
+ if test_have_prereq MINGW
194
+ then
195
+ test "$systempath" = "nul"
196
+ else
197
+ test "$systempath" = "/dev/null"
198
+ fi &&
199
+ systempath=$(GIT_CONFIG_SYSTEM="$TRASHDIR/gitconfig" git var GIT_CONFIG_SYSTEM) &&
200
+ test "$systempath" = "$TRASHDIR/gitconfig"
201
+ )
202
+'
203
+
204
+test_expect_success 'GIT_CONFIG_GLOBAL points to the correct location' '
205
+ TRASHDIR="$(test-tool path-utils normalize_path_copy "$(pwd)")" &&
206
+ HOME="$TRASHDIR" XDG_CONFIG_HOME="$TRASHDIR/foo" git var GIT_CONFIG_GLOBAL >actual &&
207
+ echo "$TRASHDIR/foo/git/config" >expected &&
208
+ echo "$TRASHDIR/.gitconfig" >>expected &&
209
+ test_cmp expected actual &&
210
+ (
211
+ sane_unset XDG_CONFIG_HOME &&
212
+ HOME="$TRASHDIR" git var GIT_CONFIG_GLOBAL >actual &&
213
+ echo "$TRASHDIR/.config/git/config" >expected &&
214
+ echo "$TRASHDIR/.gitconfig" >>expected &&
215
+ test_cmp expected actual &&
216
+ globalpath=$(GIT_CONFIG_GLOBAL=/dev/null git var GIT_CONFIG_GLOBAL) &&
217
+ if test_have_prereq MINGW
218
+ then
219
+ test "$globalpath" = "nul"
220
+ else
221
+ test "$globalpath" = "/dev/null"
222
+ fi &&
223
+ globalpath=$(GIT_CONFIG_GLOBAL="$TRASHDIR/gitconfig" git var GIT_CONFIG_GLOBAL) &&
224
+ test "$globalpath" = "$TRASHDIR/gitconfig"
225
+ )
226
+'
227
+
228
# For git var -l, we check only a representative variable;
229
# testing the whole output would make our test too brittle with
230
# respect to unrelated changes in the test suite's environment.
242
test_cmp expect actual.bare
243
'
244
245
+test_expect_success 'git var -l lists multiple global configs' '
246
+ TRASHDIR="$(test-tool path-utils normalize_path_copy "$(pwd)")" &&
247
+ HOME="$TRASHDIR" XDG_CONFIG_HOME="$TRASHDIR/foo" git var -l >actual &&
248
+ grep "^GIT_CONFIG_GLOBAL=" actual >filtered &&
249
+ echo "GIT_CONFIG_GLOBAL=$TRASHDIR/foo/git/config" >expected &&
250
+ echo "GIT_CONFIG_GLOBAL=$TRASHDIR/.gitconfig" >>expected &&
251
+ test_cmp expected filtered
252
+'
253
+
254
+test_expect_success 'git var -l does not split multiline editors' '
255
+ (
256
+ GIT_EDITOR="!f() {
257
+ echo Hello!
258
+ }; f" &&
259
+ export GIT_EDITOR &&
260
+ echo "GIT_EDITOR=$GIT_EDITOR" >expected &&
261
+ git var -l >var &&
262
+ sed -n -e "/^GIT_EDITOR/,\$p" var | head -n 3 >actual &&
263
+ test_cmp expected actual
264
+ )
265
+'
266
+
267
test_expect_success 'listing and asking for variables are exclusive' '
268
test_must_fail git var -l GIT_COMMITTER_IDENT
269
'