Skip to content

Commit d988e80

Browse files
committed
Merge branch 'bl/pretty-shorthand-config-fix'
The "--pretty=<shortHand>" option of the commands in the "git log" family, defined as "[pretty] shortHand = <expansion>" should have been looked up case insensitively, but was not, which has been corrected. * bl/pretty-shorthand-config-fix: pretty: find pretty formats case-insensitively pretty: update tests to use `test_config`
2 parents 4cc302e + f999d51 commit d988e80

File tree

2 files changed

+23
-17
lines changed

2 files changed

+23
-17
lines changed

pretty.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ static struct cmt_fmt_map *find_commit_format_recursive(const char *sought,
147147
for (i = 0; i < commit_formats_len; i++) {
148148
size_t match_len;
149149

150-
if (!starts_with(commit_formats[i].name, sought))
150+
if (!istarts_with(commit_formats[i].name, sought))
151151
continue;
152152

153153
match_len = strlen(commit_formats[i].name);

t/t4205-log-pretty-formats.sh

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,40 +30,46 @@ 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

61+
test_expect_success 'alias user-defined format is matched case-insensitively' '
62+
git log --pretty="format:%h" >expected &&
63+
test_config pretty.testone "format:%h" &&
64+
test_config pretty.testtwo testOne &&
65+
git log --pretty=testTwo >actual &&
66+
test_cmp expected actual
67+
'
68+
6269
test_expect_success 'alias user-defined tformat with %s (ISO8859-1 encoding)' '
63-
git config i18n.logOutputEncoding $test_encoding &&
70+
test_config i18n.logOutputEncoding $test_encoding &&
6471
git log --oneline >expected-s &&
6572
git log --pretty="tformat:%h %s" >actual-s &&
66-
git config --unset i18n.logOutputEncoding &&
6773
test_cmp expected-s actual-s
6874
'
6975

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

7682
test_expect_success 'alias user-defined tformat' '
7783
git log --pretty="tformat:%h" >expected &&
78-
git config pretty.test-alias "tformat:%h" &&
84+
test_config pretty.test-alias "tformat:%h" &&
7985
git log --pretty=test-alias >actual &&
8086
test_cmp expected actual
8187
'
8288

8389
test_expect_success 'alias non-existent format' '
84-
git config pretty.test-alias format-that-will-never-exist &&
90+
test_config pretty.test-alias format-that-will-never-exist &&
8591
test_must_fail git log --pretty=test-alias
8692
'
8793

8894
test_expect_success 'alias of an alias' '
8995
git log --pretty="tformat:%h" >expected &&
90-
git config pretty.test-foo "tformat:%h" &&
91-
git config pretty.test-bar test-foo &&
96+
test_config pretty.test-foo "tformat:%h" &&
97+
test_config pretty.test-bar test-foo &&
9298
git log --pretty=test-bar >actual && test_cmp expected actual
9399
'
94100

95101
test_expect_success 'alias masking an alias' '
96102
git log --pretty=format:"Two %H" >expected &&
97-
git config pretty.duplicate "format:One %H" &&
98-
git config --add pretty.duplicate "format:Two %H" &&
103+
test_config pretty.duplicate "format:One %H" &&
104+
test_config pretty.duplicate "format:Two %H" --add &&
99105
git log --pretty=duplicate >actual &&
100106
test_cmp expected actual
101107
'
102108

103109
test_expect_success 'alias loop' '
104-
git config pretty.test-foo test-bar &&
105-
git config pretty.test-bar test-foo &&
110+
test_config pretty.test-foo test-bar &&
111+
test_config pretty.test-bar test-foo &&
106112
test_must_fail git log --pretty=test-foo
107113
'
108114

0 commit comments

Comments
 (0)