Skip to content

Commit f7e8714

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 551a3e6 commit f7e8714

File tree

5 files changed

+17
-18
lines changed

5 files changed

+17
-18
lines changed

t/t1300-repo-config.sh

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ test_expect_success 'new variable inserts into proper section' '
461461
test_cmp expect .git/config
462462
'
463463

464-
test_expect_success 'alternative GIT_CONFIG (non-existing file should fail)' '
464+
test_expect_success 'alternative --file (non-existing file should fail)' '
465465
test_must_fail git config --file non-existing-config -l
466466
'
467467

@@ -495,10 +495,10 @@ test_expect_success 'refer config from subdirectory' '
495495
496496
'
497497

498-
test_expect_success 'refer config from subdirectory via GIT_CONFIG' '
498+
test_expect_success 'refer config from subdirectory via --file' '
499499
(
500500
cd x &&
501-
GIT_CONFIG=../other-config git config --get ein.bahn >actual &&
501+
git config --file=../other-config --get ein.bahn >actual &&
502502
test_cmp expect actual
503503
)
504504
'
@@ -510,8 +510,8 @@ cat > expect << EOF
510510
park = ausweis
511511
EOF
512512

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 &&
515515
test_cmp expect other-config
516516
'
517517

@@ -942,20 +942,20 @@ test_expect_success 'inner whitespace kept verbatim' '
942942

943943
test_expect_success SYMLINKS 'symlinked configuration' '
944944
ln -s notyet myconfig &&
945-
GIT_CONFIG=myconfig git config test.frotz nitfol &&
945+
git config --file=myconfig test.frotz nitfol &&
946946
test -h myconfig &&
947947
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 &&
950950
test -h myconfig &&
951951
test -f notyet &&
952952
cat >expect <<-\EOF &&
953953
nitfol
954954
rezrov
955955
EOF
956956
{
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
959959
} >actual &&
960960
test_cmp expect actual
961961
'

t/t1302-repo-version.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ test_expect_success 'setup' '
1919
2020
test_create_repo "test" &&
2121
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
2323
'
2424

2525
test_expect_success 'gitdir selection on normal repos' '

t/t7400-submodule-basic.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,7 @@ test_expect_success 'submodule add in subdirectory with relative path should fai
249249
'
250250

251251
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
254253
'
255254

256255
test_expect_success 'status should fail for unmapped paths' '
@@ -264,7 +263,7 @@ test_expect_success 'setup - map path in .gitmodules' '
264263
path = init
265264
EOF
266265
267-
GIT_CONFIG=.gitmodules git config submodule.example.path init &&
266+
git config --file=.gitmodules submodule.example.path init &&
268267
269268
test_cmp expect .gitmodules
270269
'

t/t9130-git-svn-authors-file.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ test_expect_success 'fetch fails on ee' '
6767
'
6868

6969
tmp_config_get () {
70-
GIT_CONFIG=.git/svn/.metadata git config --get "$1"
70+
git config --file=.git/svn/.metadata --get "$1"
7171
}
7272

7373
test_expect_success 'failure happened without negative side effects' '

t/t9154-git-svn-fancy-glob.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ test_expect_success 'add red branch' "
2222
"
2323

2424
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 &&
2626
git config svn-remote.svn.branches 'branches/{red,gre}:refs/remotes/*' &&
2727
git svn fetch &&
2828
git rev-parse refs/remotes/red &&
@@ -31,7 +31,7 @@ test_expect_success 'add gre branch' "
3131
"
3232

3333
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 &&
3535
git config svn-remote.svn.branches 'branches/{red,green}:refs/remotes/*' &&
3636
git svn fetch &&
3737
git rev-parse refs/remotes/red &&
@@ -40,7 +40,7 @@ test_expect_success 'add green branch' "
4040
"
4141

4242
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 &&
4444
git config svn-remote.svn.branches 'branches/*:refs/remotes/*' &&
4545
git svn fetch &&
4646
git rev-parse refs/remotes/red &&

0 commit comments

Comments
 (0)