Skip to content

Commit bd19ee9

Browse files
rscharfegitster
authored andcommitted
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 <[email protected]> Signed-off-by: René Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4416b86 commit bd19ee9

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

pretty.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1873,14 +1873,13 @@ static size_t format_commit_item(struct strbuf *sb, /* in UTF-8 */
18731873

18741874
void userformat_find_requirements(const char *fmt, struct userformat_want *w)
18751875
{
1876-
struct strbuf dummy = STRBUF_INIT;
1877-
18781876
if (!fmt) {
18791877
if (!user_format)
18801878
return;
18811879
fmt = user_format;
18821880
}
1883-
while (strbuf_expand_step(&dummy, &fmt)) {
1881+
while ((fmt = strchr(fmt, '%'))) {
1882+
fmt++;
18841883
if (skip_prefix(fmt, "%", &fmt))
18851884
continue;
18861885

@@ -1900,7 +1899,6 @@ void userformat_find_requirements(const char *fmt, struct userformat_want *w)
19001899
break;
19011900
}
19021901
}
1903-
strbuf_release(&dummy);
19041902
}
19051903

19061904
void repo_format_commit_message(struct repository *r,

0 commit comments

Comments
 (0)