Skip to content

Commit 2cd134f

Browse files
zivarahgitster
authored andcommitted
pretty: update tests to use test_config
These tests use raw `git config` calls, which is an older style that can cause config to bleed between tests if not manually unset. `test_config` ensures that config is unset at the end of each test automatically. `test_config` is chosen over `git -c` since `test_config` still ends up calling `git config` which seems slightly more realistic to how pretty formats would be defined normally. Suggested-by: Jeff King <[email protected]> Signed-off-by: Brian Lyles <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0d1bd1d commit 2cd134f

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

t/t4205-log-pretty-formats.sh

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,40 +30,38 @@ test_expect_success 'set up basic repos' '
3030
>bar &&
3131
git add foo &&
3232
test_tick &&
33-
git config i18n.commitEncoding $test_encoding &&
33+
test_config i18n.commitEncoding $test_encoding &&
3434
commit_msg $test_encoding | git commit -F - &&
3535
git add bar &&
3636
test_tick &&
37-
git commit -m "add bar" &&
38-
git config --unset i18n.commitEncoding
37+
git commit -m "add bar"
3938
'
4039

4140
test_expect_success 'alias builtin format' '
4241
git log --pretty=oneline >expected &&
43-
git config pretty.test-alias oneline &&
42+
test_config pretty.test-alias oneline &&
4443
git log --pretty=test-alias >actual &&
4544
test_cmp expected actual
4645
'
4746

4847
test_expect_success 'alias masking builtin format' '
4948
git log --pretty=oneline >expected &&
50-
git config pretty.oneline "%H" &&
49+
test_config pretty.oneline "%H" &&
5150
git log --pretty=oneline >actual &&
5251
test_cmp expected actual
5352
'
5453

5554
test_expect_success 'alias user-defined format' '
5655
git log --pretty="format:%h" >expected &&
57-
git config pretty.test-alias "format:%h" &&
56+
test_config pretty.test-alias "format:%h" &&
5857
git log --pretty=test-alias >actual &&
5958
test_cmp expected actual
6059
'
6160

6261
test_expect_success 'alias user-defined tformat with %s (ISO8859-1 encoding)' '
63-
git config i18n.logOutputEncoding $test_encoding &&
62+
test_config i18n.logOutputEncoding $test_encoding &&
6463
git log --oneline >expected-s &&
6564
git log --pretty="tformat:%h %s" >actual-s &&
66-
git config --unset i18n.logOutputEncoding &&
6765
test_cmp expected-s actual-s
6866
'
6967

@@ -75,34 +73,34 @@ test_expect_success 'alias user-defined tformat with %s (utf-8 encoding)' '
7573

7674
test_expect_success 'alias user-defined tformat' '
7775
git log --pretty="tformat:%h" >expected &&
78-
git config pretty.test-alias "tformat:%h" &&
76+
test_config pretty.test-alias "tformat:%h" &&
7977
git log --pretty=test-alias >actual &&
8078
test_cmp expected actual
8179
'
8280

8381
test_expect_success 'alias non-existent format' '
84-
git config pretty.test-alias format-that-will-never-exist &&
82+
test_config pretty.test-alias format-that-will-never-exist &&
8583
test_must_fail git log --pretty=test-alias
8684
'
8785

8886
test_expect_success 'alias of an alias' '
8987
git log --pretty="tformat:%h" >expected &&
90-
git config pretty.test-foo "tformat:%h" &&
91-
git config pretty.test-bar test-foo &&
88+
test_config pretty.test-foo "tformat:%h" &&
89+
test_config pretty.test-bar test-foo &&
9290
git log --pretty=test-bar >actual && test_cmp expected actual
9391
'
9492

9593
test_expect_success 'alias masking an alias' '
9694
git log --pretty=format:"Two %H" >expected &&
97-
git config pretty.duplicate "format:One %H" &&
98-
git config --add pretty.duplicate "format:Two %H" &&
95+
test_config pretty.duplicate "format:One %H" &&
96+
test_config pretty.duplicate "format:Two %H" --add &&
9997
git log --pretty=duplicate >actual &&
10098
test_cmp expected actual
10199
'
102100

103101
test_expect_success 'alias loop' '
104-
git config pretty.test-foo test-bar &&
105-
git config pretty.test-bar test-foo &&
102+
test_config pretty.test-foo test-bar &&
103+
test_config pretty.test-bar test-foo &&
106104
test_must_fail git log --pretty=test-foo
107105
'
108106

0 commit comments

Comments
 (0)