From: Brian Lyles <brianmlyles@gmail.com>
To: git@vger.kernel.org
Cc: Brian Lyles <brianmlyles@gmail.com>, peff@peff.net
Subject: [PATCH v2 2/2] pretty: find pretty formats case-insensitively
Date: Mon, 25 Mar 2024 02:25:13 -0500 [thread overview]
Message-ID: <20240325072651.947505-2-brianmlyles@gmail.com> (raw)
In-Reply-To: <20240324214316.917513-1-brianmlyles@gmail.com>
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
3c2a3fdc38
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 <peff@peff.net>
Signed-off-by: Brian Lyles <brianmlyles@gmail.com>
---
pretty.c | 2 +-
t/t4205-log-pretty-formats.sh | 8 ++++++++
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/pretty.c b/pretty.c
index cf964b060c..8c1092c790 100644
--- a/pretty.c
+++ b/pretty.c
@@ -147,7 +147,7 @@ static struct cmt_fmt_map *find_commit_format_recursive(const char *sought,
for (i = 0; i < commit_formats_len; i++) {
size_t match_len;
- if (!starts_with(commit_formats[i].name, sought))
+ if (!istarts_with(commit_formats[i].name, sought))
continue;
match_len = strlen(commit_formats[i].name);
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index 20bba76c43..749363ccb8 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -58,6 +58,14 @@ test_expect_success 'alias user-defined format' '
test_cmp expected actual
'
+test_expect_success 'alias user-defined format is matched case-insensitively' '
+ git log --pretty="format:%h" >expected &&
+ test_config pretty.testone "format:%h" &&
+ test_config pretty.testtwo testOne &&
+ git log --pretty=testTwo >actual &&
+ test_cmp expected actual
+'
+
test_expect_success 'alias user-defined tformat with %s (ISO8859-1 encoding)' '
test_config i18n.logOutputEncoding $test_encoding &&
git log --oneline >expected-s &&
--
2.43.2
next prev parent reply other threads:[~2024-03-25 7:27 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-24 21:43 [PATCH] pretty: find pretty formats case-insensitively Brian Lyles
2024-03-25 6:14 ` Jeff King
2024-03-25 7:08 ` Brian Lyles
2024-03-25 18:12 ` Junio C Hamano
2024-03-25 7:25 ` [PATCH v2 1/2] pretty: update tests to use `test_config` Brian Lyles
2024-03-25 9:44 ` Jeff King
2024-03-25 7:25 ` Brian Lyles [this message]
2024-03-25 9:46 ` [PATCH v2 2/2] pretty: find pretty formats case-insensitively Jeff King
2024-03-25 15:58 ` Brian Lyles
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240325072651.947505-2-brianmlyles@gmail.com \
--to=brianmlyles@gmail.com \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).