Skip to content

Commit 631bc94

Browse files
committed
Merge branch 'yd/use-test-config-unconfig'
Bulk-update of the test suite. * yd/use-test-config-unconfig: t5520: use test_config to set/unset git config variables (leftover bits) t7600: use test_config to set/unset git config variables t7502: remove clear_config t7502: use test_config to set/unset git config variables t9500: use test_config to set/unset git config variables t7508: use test_config to set/unset git config variables t7500: use test_config to set/unset git config variables t5541: use test_config to set/unset git config variables t5520: use test_config to set/unset git config variables t4202: use test_config/test_unconfig to set/unset git config variables t4034: use test_config/test_unconfig to set/unset git config variables t4304: use test_config to set/unset git config variables t3400: use test_config to set/unset git config variables
2 parents 74bd526 + 790f282 commit 631bc94

11 files changed

+75
-142
lines changed

t/t3400-rebase.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,7 @@ test_expect_success 'rebase a single mode change' '
138138
'
139139

140140
test_expect_success 'rebase is not broken by diff.renames' '
141-
git config diff.renames copies &&
142-
test_when_finished "git config --unset diff.renames" &&
141+
test_config diff.renames copies &&
143142
git checkout filemove &&
144143
GIT_TRACE=1 git rebase force-3way
145144
'

t/t3404-rebase-interactive.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -937,8 +937,7 @@ test_expect_success 'rebase --edit-todo can be used to modify todo' '
937937
test_expect_success 'rebase -i respects core.commentchar' '
938938
git reset --hard &&
939939
git checkout E^0 &&
940-
git config core.commentchar "\\" &&
941-
test_when_finished "git config --unset core.commentchar" &&
940+
test_config core.commentchar "\\" &&
942941
write_script remove-all-but-first.sh <<-\EOF &&
943942
sed -e "2,\$s/^/\\\\/" "$1" >"$1.tmp" &&
944943
mv "$1.tmp" "$1"

t/t4034-diff-words.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ test_expect_success '.gitattributes override config' '
230230
'
231231
232232
test_expect_success 'setup: remove diff driver regex' '
233-
test_might_fail git config --unset diff.testdriver.wordRegex
233+
test_unconfig diff.testdriver.wordRegex
234234
'
235235
236236
test_expect_success 'use configured regex' '
@@ -335,8 +335,7 @@ test_expect_success 'word-diff with diff.sbe' '
335335
336336
c
337337
EOF
338-
test_when_finished "git config --unset diff.suppress-blank-empty" &&
339-
git config diff.suppress-blank-empty true &&
338+
test_config diff.suppress-blank-empty true &&
340339
word_diff --word-diff=plain
341340
'
342341
@@ -368,7 +367,7 @@ test_expect_success 'setup history with two files' '
368367
369368
test_expect_success 'wordRegex for the first file does not apply to the second' '
370369
echo "*.tex diff=tex" >.gitattributes &&
371-
git config diff.tex.wordRegex "[a-z]+|." &&
370+
test_config diff.tex.wordRegex "[a-z]+|." &&
372371
cat >expect <<-\EOF &&
373372
diff --git a/a.tex b/a.tex
374373
--- a/a.tex

t/t4202-log.sh

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -419,8 +419,6 @@ test_expect_success 'log --graph with merge' '
419419
'
420420

421421
test_expect_success 'log.decorate configuration' '
422-
test_might_fail git config --unset-all log.decorate &&
423-
424422
git log --oneline >expect.none &&
425423
git log --oneline --decorate >expect.short &&
426424
git log --oneline --decorate=full >expect.full &&
@@ -429,61 +427,55 @@ test_expect_success 'log.decorate configuration' '
429427
git log --oneline >actual &&
430428
test_cmp expect.short actual &&
431429
432-
git config --unset-all log.decorate &&
433-
git config log.decorate true &&
430+
test_config log.decorate true &&
434431
git log --oneline >actual &&
435432
test_cmp expect.short actual &&
436433
git log --oneline --decorate=full >actual &&
437434
test_cmp expect.full actual &&
438435
git log --oneline --decorate=no >actual &&
439436
test_cmp expect.none actual &&
440437
441-
git config --unset-all log.decorate &&
442-
git config log.decorate no &&
438+
test_config log.decorate no &&
443439
git log --oneline >actual &&
444440
test_cmp expect.none actual &&
445441
git log --oneline --decorate >actual &&
446442
test_cmp expect.short actual &&
447443
git log --oneline --decorate=full >actual &&
448444
test_cmp expect.full actual &&
449445
450-
git config --unset-all log.decorate &&
451-
git config log.decorate 1 &&
446+
test_config log.decorate 1 &&
452447
git log --oneline >actual &&
453448
test_cmp expect.short actual &&
454449
git log --oneline --decorate=full >actual &&
455450
test_cmp expect.full actual &&
456451
git log --oneline --decorate=no >actual &&
457452
test_cmp expect.none actual &&
458453
459-
git config --unset-all log.decorate &&
460-
git config log.decorate short &&
454+
test_config log.decorate short &&
461455
git log --oneline >actual &&
462456
test_cmp expect.short actual &&
463457
git log --oneline --no-decorate >actual &&
464458
test_cmp expect.none actual &&
465459
git log --oneline --decorate=full >actual &&
466460
test_cmp expect.full actual &&
467461
468-
git config --unset-all log.decorate &&
469-
git config log.decorate full &&
462+
test_config log.decorate full &&
470463
git log --oneline >actual &&
471464
test_cmp expect.full actual &&
472465
git log --oneline --no-decorate >actual &&
473466
test_cmp expect.none actual &&
474467
git log --oneline --decorate >actual &&
475468
test_cmp expect.short actual
476469
477-
git config --unset-all log.decorate &&
470+
test_unconfig log.decorate &&
478471
git log --pretty=raw >expect.raw &&
479-
git config log.decorate full &&
472+
test_config log.decorate full &&
480473
git log --pretty=raw >actual &&
481474
test_cmp expect.raw actual
482475
483476
'
484477

485478
test_expect_success 'reflog is expected format' '
486-
test_might_fail git config --remove-section log &&
487479
git log -g --abbrev-commit --pretty=oneline >expect &&
488480
git reflog >actual &&
489481
test_cmp expect actual
@@ -496,10 +488,6 @@ test_expect_success 'whatchanged is expected format' '
496488
'
497489

498490
test_expect_success 'log.abbrevCommit configuration' '
499-
test_when_finished "git config --unset log.abbrevCommit" &&
500-
501-
test_might_fail git config --unset log.abbrevCommit &&
502-
503491
git log --abbrev-commit >expect.log.abbrev &&
504492
git log --no-abbrev-commit >expect.log.full &&
505493
git log --pretty=raw >expect.log.raw &&
@@ -508,7 +496,7 @@ test_expect_success 'log.abbrevCommit configuration' '
508496
git whatchanged --abbrev-commit >expect.whatchanged.abbrev &&
509497
git whatchanged --no-abbrev-commit >expect.whatchanged.full &&
510498
511-
git config log.abbrevCommit true &&
499+
test_config log.abbrevCommit true &&
512500
513501
git log >actual &&
514502
test_cmp expect.log.abbrev actual &&

t/t5520-pull.sh

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -96,28 +96,24 @@ test_expect_success '--rebase' '
9696
'
9797
test_expect_success 'pull.rebase' '
9898
git reset --hard before-rebase &&
99-
git config --bool pull.rebase true &&
100-
test_when_finished "git config --unset pull.rebase" &&
99+
test_config pull.rebase true &&
101100
git pull . copy &&
102101
test $(git rev-parse HEAD^) = $(git rev-parse copy) &&
103102
test new = $(git show HEAD:file2)
104103
'
105104

106105
test_expect_success 'branch.to-rebase.rebase' '
107106
git reset --hard before-rebase &&
108-
git config --bool branch.to-rebase.rebase true &&
109-
test_when_finished "git config --unset branch.to-rebase.rebase" &&
107+
test_config branch.to-rebase.rebase true &&
110108
git pull . copy &&
111109
test $(git rev-parse HEAD^) = $(git rev-parse copy) &&
112110
test new = $(git show HEAD:file2)
113111
'
114112

115113
test_expect_success 'branch.to-rebase.rebase should override pull.rebase' '
116114
git reset --hard before-rebase &&
117-
git config --bool pull.rebase true &&
118-
test_when_finished "git config --unset pull.rebase" &&
119-
git config --bool branch.to-rebase.rebase false &&
120-
test_when_finished "git config --unset branch.to-rebase.rebase" &&
115+
test_config pull.rebase true &&
116+
test_config branch.to-rebase.rebase false &&
121117
git pull . copy &&
122118
test $(git rev-parse HEAD^) != $(git rev-parse copy) &&
123119
test new = $(git show HEAD:file2)
@@ -171,9 +167,9 @@ test_expect_success 'pull --rebase dies early with dirty working directory' '
171167
git update-ref refs/remotes/me/copy copy^ &&
172168
COPY=$(git rev-parse --verify me/copy) &&
173169
git rebase --onto $COPY copy &&
174-
git config branch.to-rebase.remote me &&
175-
git config branch.to-rebase.merge refs/heads/copy &&
176-
git config branch.to-rebase.rebase true &&
170+
test_config branch.to-rebase.remote me &&
171+
test_config branch.to-rebase.merge refs/heads/copy &&
172+
test_config branch.to-rebase.rebase true &&
177173
echo dirty >> file &&
178174
git add file &&
179175
test_must_fail git pull &&

t/t5541-http-push.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,7 @@ test_expect_success 'push (chunked)' '
181181
git checkout master &&
182182
test_commit commit path3 &&
183183
HEAD=$(git rev-parse --verify HEAD) &&
184-
git config http.postbuffer 4 &&
185-
test_when_finished "git config --unset http.postbuffer" &&
184+
test_config http.postbuffer 4 &&
186185
git push -v -v origin $BRANCH 2>err &&
187186
grep "POST git-receive-pack (chunked)" err &&
188187
(cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&

t/t7500-commit.sh

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ test_expect_success 'nonexistent template file should return error' '
3636
'
3737

3838
test_expect_success 'nonexistent template file in config should return error' '
39-
git config commit.template "$PWD"/notexist &&
40-
test_when_finished "git config --unset commit.template" &&
39+
test_config commit.template "$PWD"/notexist &&
4140
(
4241
GIT_EDITOR="echo hello >\"\$1\"" &&
4342
export GIT_EDITOR &&
@@ -93,14 +92,13 @@ test_expect_success '-t option should be short for --template' '
9392

9493
test_expect_success 'config-specified template should commit' '
9594
echo "new template" > "$TEMPLATE" &&
96-
git config commit.template "$TEMPLATE" &&
95+
test_config commit.template "$TEMPLATE" &&
9796
echo "more content" >> foo &&
9897
git add foo &&
9998
(
10099
test_set_editor "$TEST_DIRECTORY"/t7500/add-content &&
101100
git commit
102101
) &&
103-
git config --unset commit.template &&
104102
commit_msg_is "new templatecommit message"
105103
'
106104

t/t7502-commit.sh

Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,9 @@ test_expect_success 'verbose' '
171171

172172
test_expect_success 'verbose respects diff config' '
173173
174-
git config color.diff always &&
174+
test_config color.diff always &&
175175
git status -v >actual &&
176-
grep "\[1mdiff --git" actual &&
177-
git config --unset color.diff
176+
grep "\[1mdiff --git" actual
178177
'
179178

180179
mesg_with_comment_and_newlines='
@@ -435,16 +434,6 @@ EOF
435434

436435
echo '## Custom template' >template
437436

438-
clear_config () {
439-
(
440-
git config --unset-all "$1"
441-
case $? in
442-
0|5) exit 0 ;;
443-
*) exit 1 ;;
444-
esac
445-
)
446-
}
447-
448437
try_commit () {
449438
git reset --hard &&
450439
echo >>negative &&
@@ -460,67 +449,57 @@ try_commit () {
460449
try_commit_status_combo () {
461450

462451
test_expect_success 'commit' '
463-
clear_config commit.status &&
464452
try_commit "" &&
465453
test_i18ngrep "^# Changes to be committed:" .git/COMMIT_EDITMSG
466454
'
467455

468456
test_expect_success 'commit' '
469-
clear_config commit.status &&
470457
try_commit "" &&
471458
test_i18ngrep "^# Changes to be committed:" .git/COMMIT_EDITMSG
472459
'
473460

474461
test_expect_success 'commit --status' '
475-
clear_config commit.status &&
476462
try_commit --status &&
477463
test_i18ngrep "^# Changes to be committed:" .git/COMMIT_EDITMSG
478464
'
479465

480466
test_expect_success 'commit --no-status' '
481-
clear_config commit.status &&
482467
try_commit --no-status &&
483468
test_i18ngrep ! "^# Changes to be committed:" .git/COMMIT_EDITMSG
484469
'
485470

486471
test_expect_success 'commit with commit.status = yes' '
487-
clear_config commit.status &&
488-
git config commit.status yes &&
472+
test_config commit.status yes &&
489473
try_commit "" &&
490474
test_i18ngrep "^# Changes to be committed:" .git/COMMIT_EDITMSG
491475
'
492476

493477
test_expect_success 'commit with commit.status = no' '
494-
clear_config commit.status &&
495-
git config commit.status no &&
478+
test_config commit.status no &&
496479
try_commit "" &&
497480
test_i18ngrep ! "^# Changes to be committed:" .git/COMMIT_EDITMSG
498481
'
499482

500483
test_expect_success 'commit --status with commit.status = yes' '
501-
clear_config commit.status &&
502-
git config commit.status yes &&
484+
test_config commit.status yes &&
503485
try_commit --status &&
504486
test_i18ngrep "^# Changes to be committed:" .git/COMMIT_EDITMSG
505487
'
506488

507489
test_expect_success 'commit --no-status with commit.status = yes' '
508-
clear_config commit.status &&
509-
git config commit.status yes &&
490+
test_config commit.status yes &&
510491
try_commit --no-status &&
511492
test_i18ngrep ! "^# Changes to be committed:" .git/COMMIT_EDITMSG
512493
'
513494

514495
test_expect_success 'commit --status with commit.status = no' '
515-
clear_config commit.status &&
516-
git config commit.status no &&
496+
test_config commit.status no &&
517497
try_commit --status &&
518498
test_i18ngrep "^# Changes to be committed:" .git/COMMIT_EDITMSG
519499
'
520500

521501
test_expect_success 'commit --no-status with commit.status = no' '
522-
clear_config commit.status &&
523-
git config commit.status no &&
502+
test_config commit.status no &&
524503
try_commit --no-status &&
525504
test_i18ngrep ! "^# Changes to be committed:" .git/COMMIT_EDITMSG
526505
'
@@ -534,8 +513,7 @@ use_template="-t template"
534513
try_commit_status_combo
535514

536515
test_expect_success 'commit --status with custom comment character' '
537-
test_when_finished "git config --unset core.commentchar" &&
538-
git config core.commentchar ";" &&
516+
test_config core.commentchar ";" &&
539517
try_commit --status &&
540518
test_i18ngrep "^; Changes to be committed:" .git/COMMIT_EDITMSG
541519
'

0 commit comments

Comments
 (0)