Skip to content

Commit f999d51

Browse files
zivarahpeff
authored andcommitted
pretty: find pretty formats case-insensitively
User-defined pretty formats are stored in config, which is meant to use case-insensitive matching for names as noted in config.txt's 'Syntax' section: All the other lines [...] are recognized as setting variables, in the form 'name = value' [...]. The variable names are case-insensitive, [...]. When a user specifies one of their format aliases with an uppercase in it, however, it is not found. $ git config pretty.testAlias %h $ git config --list | grep pretty pretty.testalias=%h $ git log --format=testAlias -1 fatal: invalid --pretty format: testAlias $ git log --format=testalias -1 3c2a3fd This is true whether the name in the config file uses any uppercase characters or not. Use case-insensitive comparisons when identifying format aliases. Co-authored-by: Jeff King <[email protected]> Signed-off-by: Brian Lyles <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2cd134f commit f999d51

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

pretty.c

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

143-
if (!starts_with(commit_formats[i].name, sought))
143+
if (!istarts_with(commit_formats[i].name, sought))
144144
continue;
145145

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

t/t4205-log-pretty-formats.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,14 @@ test_expect_success 'alias user-defined format' '
5858
test_cmp expected actual
5959
'
6060

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+
6169
test_expect_success 'alias user-defined tformat with %s (ISO8859-1 encoding)' '
6270
test_config i18n.logOutputEncoding $test_encoding &&
6371
git log --oneline >expected-s &&

0 commit comments

Comments
 (0)