t: prefer "git config --file" to GIT_CONFIG

Doing: GIT_CONFIG=foo git config ... is equivalent to: git config --file=foo ... The latter is easier to read and slightly less error-prone, because of issues with one-shot variables and shell functions (e.g., you cannot use the former with test_must_fail). Note that we explicitly leave one case in t1300 which checks the same operation on both GIT_CONFIG and "git config --file". They are equivalent in the code these days, but this will make sure it remains so. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Mar 20, 2014 at 19:17 UTC f7e87141011fc55f8267ea76d3cc016ee87f9053
5 files changed +17 -18
t/t1300-repo-config.sh
+10 -10
@@ -461,7 +461,7 @@ test_expect_success 'new variable inserts into proper section' '
461 test_cmp expect .git/config
462 '
463
464 -test_expect_success 'alternative GIT_CONFIG (non-existing file should fail)' '
464 +test_expect_success 'alternative --file (non-existing file should fail)' '
465 test_must_fail git config --file non-existing-config -l
466 '
467
@@ -495,10 +495,10 @@ test_expect_success 'refer config from subdirectory' '
495
496 '
497
498 -test_expect_success 'refer config from subdirectory via GIT_CONFIG' '
498 +test_expect_success 'refer config from subdirectory via --file' '
499 (
500 cd x &&
501 - GIT_CONFIG=../other-config git config --get ein.bahn >actual &&
501 + git config --file=../other-config --get ein.bahn >actual &&
502 test_cmp expect actual
503 )
504 '
@@ -510,8 +510,8 @@ cat > expect << EOF
510 park = ausweis
511 EOF
512
513 -test_expect_success '--set in alternative GIT_CONFIG' '
514 - GIT_CONFIG=other-config git config anwohner.park ausweis &&
513 +test_expect_success '--set in alternative file' '
514 + git config --file=other-config anwohner.park ausweis &&
515 test_cmp expect other-config
516 '
517
@@ -942,11 +942,11 @@ test_expect_success 'inner whitespace kept verbatim' '
942
943 test_expect_success SYMLINKS 'symlinked configuration' '
944 ln -s notyet myconfig &&
945 - GIT_CONFIG=myconfig git config test.frotz nitfol &&
945 + git config --file=myconfig test.frotz nitfol &&
946 test -h myconfig &&
947 test -f notyet &&
948 - test "z$(GIT_CONFIG=notyet git config test.frotz)" = znitfol &&
949 - GIT_CONFIG=myconfig git config test.xyzzy rezrov &&
948 + test "z$(git config --file=notyet test.frotz)" = znitfol &&
949 + git config --file=myconfig test.xyzzy rezrov &&
950 test -h myconfig &&
951 test -f notyet &&
952 cat >expect <<-\EOF &&
@@ -954,8 +954,8 @@ test_expect_success SYMLINKS 'symlinked configuration' '
954 rezrov
955 EOF
956 {
957 - GIT_CONFIG=notyet git config test.frotz &&
958 - GIT_CONFIG=notyet git config test.xyzzy
957 + git config --file=notyet test.frotz &&
958 + git config --file=notyet test.xyzzy
959 } >actual &&
960 test_cmp expect actual
961 '
t/t1302-repo-version.sh
+1 -1
@@ -19,7 +19,7 @@ test_expect_success 'setup' '
19
20 test_create_repo "test" &&
21 test_create_repo "test2" &&
22 - GIT_CONFIG=test2/.git/config git config core.repositoryformatversion 99
22 + git config --file=test2/.git/config core.repositoryformatversion 99
23 '
24
25 test_expect_success 'gitdir selection on normal repos' '
t/t7400-submodule-basic.sh
+2 -3
@@ -249,8 +249,7 @@ test_expect_success 'submodule add in subdirectory with relative path should fai
249 '
250
251 test_expect_success 'setup - add an example entry to .gitmodules' '
252 - GIT_CONFIG=.gitmodules \
253 - git config submodule.example.url git://example.com/init.git
252 + git config --file=.gitmodules submodule.example.url git://example.com/init.git
253 '
254
255 test_expect_success 'status should fail for unmapped paths' '
@@ -264,7 +263,7 @@ test_expect_success 'setup - map path in .gitmodules' '
263 path = init
264 EOF
265
267 - GIT_CONFIG=.gitmodules git config submodule.example.path init &&
266 + git config --file=.gitmodules submodule.example.path init &&
267
268 test_cmp expect .gitmodules
269 '
t/t9130-git-svn-authors-file.sh
+1 -1
@@ -67,7 +67,7 @@ test_expect_success 'fetch fails on ee' '
67 '
68
69 tmp_config_get () {
70 - GIT_CONFIG=.git/svn/.metadata git config --get "$1"
70 + git config --file=.git/svn/.metadata --get "$1"
71 }
72
73 test_expect_success 'failure happened without negative side effects' '
t/t9154-git-svn-fancy-glob.sh
+3 -3
@@ -22,7 +22,7 @@ test_expect_success 'add red branch' "
22 "
23
24 test_expect_success 'add gre branch' "
25 - GIT_CONFIG=.git/svn/.metadata git config --unset svn-remote.svn.branches-maxRev &&
25 + git config --file=.git/svn/.metadata --unset svn-remote.svn.branches-maxRev &&
26 git config svn-remote.svn.branches 'branches/{red,gre}:refs/remotes/*' &&
27 git svn fetch &&
28 git rev-parse refs/remotes/red &&
@@ -31,7 +31,7 @@ test_expect_success 'add gre branch' "
31 "
32
33 test_expect_success 'add green branch' "
34 - GIT_CONFIG=.git/svn/.metadata git config --unset svn-remote.svn.branches-maxRev &&
34 + git config --file=.git/svn/.metadata --unset svn-remote.svn.branches-maxRev &&
35 git config svn-remote.svn.branches 'branches/{red,green}:refs/remotes/*' &&
36 git svn fetch &&
37 git rev-parse refs/remotes/red &&
@@ -40,7 +40,7 @@ test_expect_success 'add green branch' "
40 "
41
42 test_expect_success 'add all branches' "
43 - GIT_CONFIG=.git/svn/.metadata git config --unset svn-remote.svn.branches-maxRev &&
43 + git config --file=.git/svn/.metadata --unset svn-remote.svn.branches-maxRev &&
44 git config svn-remote.svn.branches 'branches/*:refs/remotes/*' &&
45 git svn fetch &&
46 git rev-parse refs/remotes/red &&