Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2023-07-07 22:08:33 +0300
committerJunio C Hamano <gitster@pobox.com>2023-07-08 01:32:57 +0300
commitbd19ee9c459b2d7872a8e486fd9c2f1b17d662a5 (patch)
treee665ab970390a9df0dbfb219e434e5ba079f7a12 /pretty.c
parent4416b86c6b34dad64b556bb1eb6711d5e6595a48 (diff)
pretty: use strchr(3) in userformat_find_requirements()
The strbuf_expand_step() loop in userformat_find_requirements() iterates through the percent signs in the string "fmt", but we're not interested in its effect on the strbuf "dummy". Use strchr(3) instead and get rid of the strbuf that we no longer need. Suggested-by: Jeff King <peff@peff.net> Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'pretty.c')
-rw-r--r--pretty.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/pretty.c b/pretty.c
index 4c08f9856b..51ee7a5f12 100644
--- a/pretty.c
+++ b/pretty.c
@@ -1873,14 +1873,13 @@ static size_t format_commit_item(struct strbuf *sb, /* in UTF-8 */
void userformat_find_requirements(const char *fmt, struct userformat_want *w)
{
- struct strbuf dummy = STRBUF_INIT;
-
if (!fmt) {
if (!user_format)
return;
fmt = user_format;
}
- while (strbuf_expand_step(&dummy, &fmt)) {
+ while ((fmt = strchr(fmt, '%'))) {
+ fmt++;
if (skip_prefix(fmt, "%", &fmt))
continue;
@@ -1900,7 +1899,6 @@ void userformat_find_requirements(const char *fmt, struct userformat_want *w)
break;
}
}
- strbuf_release(&dummy);
}
void repo_format_commit_message(struct repository *r,