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>
This commit is contained in:
Jeff King 2014-03-20 19:17:01 -04:00 committed by Junio C Hamano
parent 551a3e60d1
commit f7e8714101
5 changed files with 17 additions and 18 deletions

View file

@ -461,7 +461,7 @@ test_expect_success 'new variable inserts into proper section' '
test_cmp expect .git/config test_cmp expect .git/config
' '
test_expect_success 'alternative GIT_CONFIG (non-existing file should fail)' ' test_expect_success 'alternative --file (non-existing file should fail)' '
test_must_fail git config --file non-existing-config -l test_must_fail git config --file non-existing-config -l
' '
@ -495,10 +495,10 @@ test_expect_success 'refer config from subdirectory' '
' '
test_expect_success 'refer config from subdirectory via GIT_CONFIG' ' test_expect_success 'refer config from subdirectory via --file' '
( (
cd x && cd x &&
GIT_CONFIG=../other-config git config --get ein.bahn >actual && git config --file=../other-config --get ein.bahn >actual &&
test_cmp expect actual test_cmp expect actual
) )
' '
@ -510,8 +510,8 @@ cat > expect << EOF
park = ausweis park = ausweis
EOF EOF
test_expect_success '--set in alternative GIT_CONFIG' ' test_expect_success '--set in alternative file' '
GIT_CONFIG=other-config git config anwohner.park ausweis && git config --file=other-config anwohner.park ausweis &&
test_cmp expect other-config test_cmp expect other-config
' '
@ -942,11 +942,11 @@ test_expect_success 'inner whitespace kept verbatim' '
test_expect_success SYMLINKS 'symlinked configuration' ' test_expect_success SYMLINKS 'symlinked configuration' '
ln -s notyet myconfig && ln -s notyet myconfig &&
GIT_CONFIG=myconfig git config test.frotz nitfol && git config --file=myconfig test.frotz nitfol &&
test -h myconfig && test -h myconfig &&
test -f notyet && test -f notyet &&
test "z$(GIT_CONFIG=notyet git config test.frotz)" = znitfol && test "z$(git config --file=notyet test.frotz)" = znitfol &&
GIT_CONFIG=myconfig git config test.xyzzy rezrov && git config --file=myconfig test.xyzzy rezrov &&
test -h myconfig && test -h myconfig &&
test -f notyet && test -f notyet &&
cat >expect <<-\EOF && cat >expect <<-\EOF &&
@ -954,8 +954,8 @@ test_expect_success SYMLINKS 'symlinked configuration' '
rezrov rezrov
EOF EOF
{ {
GIT_CONFIG=notyet git config test.frotz && git config --file=notyet test.frotz &&
GIT_CONFIG=notyet git config test.xyzzy git config --file=notyet test.xyzzy
} >actual && } >actual &&
test_cmp expect actual test_cmp expect actual
' '

View file

@ -19,7 +19,7 @@ test_expect_success 'setup' '
test_create_repo "test" && test_create_repo "test" &&
test_create_repo "test2" && test_create_repo "test2" &&
GIT_CONFIG=test2/.git/config git config core.repositoryformatversion 99 git config --file=test2/.git/config core.repositoryformatversion 99
' '
test_expect_success 'gitdir selection on normal repos' ' test_expect_success 'gitdir selection on normal repos' '

View file

@ -249,8 +249,7 @@ test_expect_success 'submodule add in subdirectory with relative path should fai
' '
test_expect_success 'setup - add an example entry to .gitmodules' ' test_expect_success 'setup - add an example entry to .gitmodules' '
GIT_CONFIG=.gitmodules \ git config --file=.gitmodules submodule.example.url git://example.com/init.git
git config submodule.example.url git://example.com/init.git
' '
test_expect_success 'status should fail for unmapped paths' ' test_expect_success 'status should fail for unmapped paths' '
@ -264,7 +263,7 @@ test_expect_success 'setup - map path in .gitmodules' '
path = init path = init
EOF EOF
GIT_CONFIG=.gitmodules git config submodule.example.path init && git config --file=.gitmodules submodule.example.path init &&
test_cmp expect .gitmodules test_cmp expect .gitmodules
' '

View file

@ -67,7 +67,7 @@ test_expect_success 'fetch fails on ee' '
' '
tmp_config_get () { tmp_config_get () {
GIT_CONFIG=.git/svn/.metadata git config --get "$1" git config --file=.git/svn/.metadata --get "$1"
} }
test_expect_success 'failure happened without negative side effects' ' test_expect_success 'failure happened without negative side effects' '

View file

@ -22,7 +22,7 @@ test_expect_success 'add red branch' "
" "
test_expect_success 'add gre branch' " test_expect_success 'add gre branch' "
GIT_CONFIG=.git/svn/.metadata git config --unset svn-remote.svn.branches-maxRev && git config --file=.git/svn/.metadata --unset svn-remote.svn.branches-maxRev &&
git config svn-remote.svn.branches 'branches/{red,gre}:refs/remotes/*' && git config svn-remote.svn.branches 'branches/{red,gre}:refs/remotes/*' &&
git svn fetch && git svn fetch &&
git rev-parse refs/remotes/red && git rev-parse refs/remotes/red &&
@ -31,7 +31,7 @@ test_expect_success 'add gre branch' "
" "
test_expect_success 'add green branch' " test_expect_success 'add green branch' "
GIT_CONFIG=.git/svn/.metadata git config --unset svn-remote.svn.branches-maxRev && git config --file=.git/svn/.metadata --unset svn-remote.svn.branches-maxRev &&
git config svn-remote.svn.branches 'branches/{red,green}:refs/remotes/*' && git config svn-remote.svn.branches 'branches/{red,green}:refs/remotes/*' &&
git svn fetch && git svn fetch &&
git rev-parse refs/remotes/red && git rev-parse refs/remotes/red &&
@ -40,7 +40,7 @@ test_expect_success 'add green branch' "
" "
test_expect_success 'add all branches' " test_expect_success 'add all branches' "
GIT_CONFIG=.git/svn/.metadata git config --unset svn-remote.svn.branches-maxRev && git config --file=.git/svn/.metadata --unset svn-remote.svn.branches-maxRev &&
git config svn-remote.svn.branches 'branches/*:refs/remotes/*' && git config svn-remote.svn.branches 'branches/*:refs/remotes/*' &&
git svn fetch && git svn fetch &&
git rev-parse refs/remotes/red && git rev-parse refs/remotes/red &&