Skip to content

Commit 3ab4c54

Browse files
committed
Merge branch 'rs/pretty-use-prefixcmp'
* rs/pretty-use-prefixcmp: pretty: use prefixcmp instead of memcmp on NUL-terminated strings
2 parents 7829253 + 8a692d2 commit 3ab4c54

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

pretty.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,7 @@ static size_t format_commit_one(struct strbuf *sb, const char *placeholder,
966966

967967
if (!end)
968968
return 0;
969-
if (!memcmp(begin, "auto,", 5)) {
969+
if (!prefixcmp(begin, "auto,")) {
970970
if (!want_color(c->pretty_ctx->color))
971971
return end - placeholder + 1;
972972
begin += 5;
@@ -1301,7 +1301,7 @@ static void pp_header(const struct pretty_print_context *pp,
13011301
continue;
13021302
}
13031303

1304-
if (!memcmp(line, "parent ", 7)) {
1304+
if (!prefixcmp(line, "parent ")) {
13051305
if (linelen != 48)
13061306
die("bad parent line in commit");
13071307
continue;
@@ -1325,11 +1325,11 @@ static void pp_header(const struct pretty_print_context *pp,
13251325
* FULL shows both authors but not dates.
13261326
* FULLER shows both authors and dates.
13271327
*/
1328-
if (!memcmp(line, "author ", 7)) {
1328+
if (!prefixcmp(line, "author ")) {
13291329
strbuf_grow(sb, linelen + 80);
13301330
pp_user_info(pp, "Author", sb, line + 7, encoding);
13311331
}
1332-
if (!memcmp(line, "committer ", 10) &&
1332+
if (!prefixcmp(line, "committer ") &&
13331333
(pp->fmt == CMIT_FMT_FULL || pp->fmt == CMIT_FMT_FULLER)) {
13341334
strbuf_grow(sb, linelen + 80);
13351335
pp_user_info(pp, "Commit", sb, line + 10, encoding);

0 commit comments

Comments
 (0)