t7600: use test_config to set/unset git config variables
Instead of using construct such as: test_when_finished "git config --unset <key>" git config <key> <value> uses test_config <key> <value> The latter takes care of removing <key> at the end of the test. Tests are modified to assume default configuration at entry, and to reset the modified configuration variables at the end. Test 'merge log message' was relying on the presence of option `--no-ff` in the configuration. With the option, git show -s --pretty=format:%b HEAD produces an empty line and without the option, it produces an empty file. The test is modified to check with and without `--no-ff` option. Signed-off-by: Yann Droneaud <ydroneaud@opteya.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Yann Droneaud committed
Mar 24, 2013 at 22:06 UTC
cee683b72eac1a1ac0fcbaabf5256a5f0aff07f7
1 file changed
+26
-34
t/t7600-merge.sh
+26
-34
@@ -56,7 +56,8 @@ create_merge_msgs () {
56
echo &&
57
git log --no-merges ^HEAD c2 c3
58
} >squash.1-5-9 &&
59
- echo >msg.nolog &&
59
+ : >msg.nologff &&
60
+ echo >msg.nolognoff &&
61
{
62
echo "* tag 'c3':" &&
63
echo " commit 3" &&
@@ -244,8 +245,7 @@ test_expect_success 'merges with --ff-only' '
245
test_expect_success 'merges with merge.ff=only' '
246
git reset --hard c1 &&
247
test_tick &&
247
- test_when_finished "git config --unset merge.ff" &&
248
- git config merge.ff only &&
248
+ test_config merge.ff "only" &&
249
test_must_fail git merge c2 &&
250
test_must_fail git merge c3 &&
251
test_must_fail git merge c2 c3 &&
@@ -336,7 +336,7 @@ test_debug 'git log --graph --decorate --oneline --all'
336
337
test_expect_success 'merge c1 with c2 (no-commit in config)' '
338
git reset --hard c1 &&
339
- git config branch.master.mergeoptions "--no-commit" &&
339
+ test_config branch.master.mergeoptions "--no-commit" &&
340
git merge c2 &&
341
verify_merge file result.1-5 &&
342
verify_head $c1 &&
@@ -346,12 +346,11 @@ test_expect_success 'merge c1 with c2 (no-commit in config)' '
346
test_debug 'git log --graph --decorate --oneline --all'
347
348
test_expect_success 'merge c1 with c2 (log in config)' '
349
- git config branch.master.mergeoptions "" &&
349
git reset --hard c1 &&
350
git merge --log c2 &&
351
git show -s --pretty=tformat:%s%n%b >expect &&
352
354
- git config branch.master.mergeoptions --log &&
353
+ test_config branch.master.mergeoptions "--log" &&
354
git reset --hard c1 &&
355
git merge c2 &&
356
git show -s --pretty=tformat:%s%n%b >actual &&
@@ -360,17 +359,12 @@ test_expect_success 'merge c1 with c2 (log in config)' '
359
'
360
361
test_expect_success 'merge c1 with c2 (log in config gets overridden)' '
363
- test_when_finished "git config --remove-section branch.master" &&
364
- test_when_finished "git config --remove-section merge" &&
365
- test_might_fail git config --remove-section branch.master &&
366
- test_might_fail git config --remove-section merge &&
367
-
362
git reset --hard c1 &&
363
git merge c2 &&
364
git show -s --pretty=tformat:%s%n%b >expect &&
365
372
- git config branch.master.mergeoptions "--no-log" &&
373
- git config merge.log true &&
366
+ test_config branch.master.mergeoptions "--no-log" &&
367
+ test_config merge.log "true" &&
368
git reset --hard c1 &&
369
git merge c2 &&
370
git show -s --pretty=tformat:%s%n%b >actual &&
@@ -380,7 +374,7 @@ test_expect_success 'merge c1 with c2 (log in config gets overridden)' '
374
375
test_expect_success 'merge c1 with c2 (squash in config)' '
376
git reset --hard c1 &&
383
- git config branch.master.mergeoptions "--squash" &&
377
+ test_config branch.master.mergeoptions "--squash" &&
378
git merge c2 &&
379
verify_merge file result.1-5 &&
380
verify_head $c1 &&
@@ -392,7 +386,7 @@ test_debug 'git log --graph --decorate --oneline --all'
386
387
test_expect_success 'override config option -n with --summary' '
388
git reset --hard c1 &&
395
- git config branch.master.mergeoptions "-n" &&
389
+ test_config branch.master.mergeoptions "-n" &&
390
test_tick &&
391
git merge --summary c2 >diffstat.txt &&
392
verify_merge file result.1-5 msg.1-5 &&
@@ -406,7 +400,7 @@ test_expect_success 'override config option -n with --summary' '
400
401
test_expect_success 'override config option -n with --stat' '
402
git reset --hard c1 &&
409
- git config branch.master.mergeoptions "-n" &&
403
+ test_config branch.master.mergeoptions "-n" &&
404
test_tick &&
405
git merge --stat c2 >diffstat.txt &&
406
verify_merge file result.1-5 msg.1-5 &&
@@ -422,7 +416,7 @@ test_debug 'git log --graph --decorate --oneline --all'
416
417
test_expect_success 'override config option --stat' '
418
git reset --hard c1 &&
425
- git config branch.master.mergeoptions "--stat" &&
419
+ test_config branch.master.mergeoptions "--stat" &&
420
test_tick &&
421
git merge -n c2 >diffstat.txt &&
422
verify_merge file result.1-5 msg.1-5 &&
@@ -438,7 +432,7 @@ test_debug 'git log --graph --decorate --oneline --all'
432
433
test_expect_success 'merge c1 with c2 (override --no-commit)' '
434
git reset --hard c1 &&
441
- git config branch.master.mergeoptions "--no-commit" &&
435
+ test_config branch.master.mergeoptions "--no-commit" &&
436
test_tick &&
437
git merge --commit c2 &&
438
verify_merge file result.1-5 msg.1-5 &&
@@ -449,7 +443,7 @@ test_debug 'git log --graph --decorate --oneline --all'
443
444
test_expect_success 'merge c1 with c2 (override --squash)' '
445
git reset --hard c1 &&
452
- git config branch.master.mergeoptions "--squash" &&
446
+ test_config branch.master.mergeoptions "--squash" &&
447
test_tick &&
448
git merge --no-squash c2 &&
449
verify_merge file result.1-5 msg.1-5 &&
@@ -460,7 +454,6 @@ test_debug 'git log --graph --decorate --oneline --all'
454
455
test_expect_success 'merge c0 with c1 (no-ff)' '
456
git reset --hard c0 &&
463
- git config branch.master.mergeoptions "" &&
457
test_tick &&
458
git merge --no-ff c1 &&
459
verify_merge file result.1 &&
@@ -471,10 +464,9 @@ test_debug 'git log --graph --decorate --oneline --all'
464
465
test_expect_success 'merge c0 with c1 (merge.ff=false)' '
466
git reset --hard c0 &&
474
- git config merge.ff false &&
467
+ test_config merge.ff "false" &&
468
test_tick &&
469
git merge c1 &&
477
- git config --remove-section merge &&
470
verify_merge file result.1 &&
471
verify_parents $c0 $c1
472
'
@@ -482,22 +474,19 @@ test_debug 'git log --graph --decorate --oneline --all'
474
475
test_expect_success 'combine branch.master.mergeoptions with merge.ff' '
476
git reset --hard c0 &&
485
- git config branch.master.mergeoptions --ff &&
486
- git config merge.ff false &&
477
+ test_config branch.master.mergeoptions "--ff" &&
478
+ test_config merge.ff "false" &&
479
test_tick &&
480
git merge c1 &&
489
- git config --remove-section "branch.master" &&
490
- git config --remove-section "merge" &&
481
verify_merge file result.1 &&
482
verify_parents "$c0"
483
'
484
485
test_expect_success 'tolerate unknown values for merge.ff' '
486
git reset --hard c0 &&
497
- git config merge.ff something-new &&
487
+ test_config merge.ff "something-new" &&
488
test_tick &&
489
git merge c1 2>message &&
500
- git config --remove-section "merge" &&
490
verify_head "$c1" &&
491
test_cmp empty message
492
'
@@ -515,7 +504,7 @@ test_expect_success 'combining --ff-only and --no-ff is refused' '
504
505
test_expect_success 'merge c0 with c1 (ff overrides no-ff)' '
506
git reset --hard c0 &&
518
- git config branch.master.mergeoptions "--no-ff" &&
507
+ test_config branch.master.mergeoptions "--no-ff" &&
508
git merge --ff c1 &&
509
verify_merge file result.1 &&
510
verify_head $c1
@@ -525,14 +514,20 @@ test_expect_success 'merge log message' '
514
git reset --hard c0 &&
515
git merge --no-log c2 &&
516
git show -s --pretty=format:%b HEAD >msg.act &&
528
- test_cmp msg.nolog msg.act &&
517
+ test_cmp msg.nologff msg.act &&
518
+
519
+ git reset --hard c0 &&
520
+ test_config branch.master.mergeoptions "--no-ff" &&
521
+ git merge --no-log c2 &&
522
+ git show -s --pretty=format:%b HEAD >msg.act &&
523
+ test_cmp msg.nolognoff msg.act &&
524
525
git merge --log c3 &&
526
git show -s --pretty=format:%b HEAD >msg.act &&
527
test_cmp msg.log msg.act &&
528
529
git reset --hard HEAD^ &&
535
- git config merge.log yes &&
530
+ test_config merge.log "yes" &&
531
git merge c3 &&
532
git show -s --pretty=format:%b HEAD >msg.act &&
533
test_cmp msg.log msg.act
@@ -542,7 +537,6 @@ test_debug 'git log --graph --decorate --oneline --all'
537
538
test_expect_success 'merge c1 with c0, c2, c0, and c1' '
539
git reset --hard c1 &&
545
- git config branch.master.mergeoptions "" &&
540
test_tick &&
541
git merge c0 c2 c0 c1 &&
542
verify_merge file result.1-5 &&
@@ -553,7 +547,6 @@ test_debug 'git log --graph --decorate --oneline --all'
547
548
test_expect_success 'merge c1 with c0, c2, c0, and c1' '
549
git reset --hard c1 &&
556
- git config branch.master.mergeoptions "" &&
550
test_tick &&
551
git merge c0 c2 c0 c1 &&
552
verify_merge file result.1-5 &&
@@ -564,7 +557,6 @@ test_debug 'git log --graph --decorate --oneline --all'
557
558
test_expect_success 'merge c1 with c1 and c2' '
559
git reset --hard c1 &&
567
- git config branch.master.mergeoptions "" &&
560
test_tick &&
561
git merge c1 c2 &&
562
verify_merge file result.1-5 &&