Skip to content

Commit

Permalink
Merge branch 'rs/pretty-use-prefixcmp'
Browse files Browse the repository at this point in the history
* rs/pretty-use-prefixcmp:
  pretty: use prefixcmp instead of memcmp on NUL-terminated strings
  • Loading branch information
Junio C Hamano committed Jan 18, 2013
2 parents 7829253 + 8a692d2 commit 3ab4c54
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pretty.c
Original file line number Diff line number Diff line change
Expand Up @@ -966,7 +966,7 @@ static size_t format_commit_one(struct strbuf *sb, const char *placeholder,

if (!end)
return 0;
if (!memcmp(begin, "auto,", 5)) {
if (!prefixcmp(begin, "auto,")) {
if (!want_color(c->pretty_ctx->color))
return end - placeholder + 1;
begin += 5;
Expand Down Expand Up @@ -1301,7 +1301,7 @@ static void pp_header(const struct pretty_print_context *pp,
continue;
}

if (!memcmp(line, "parent ", 7)) {
if (!prefixcmp(line, "parent ")) {
if (linelen != 48)
die("bad parent line in commit");
continue;
Expand All @@ -1325,11 +1325,11 @@ static void pp_header(const struct pretty_print_context *pp,
* FULL shows both authors but not dates.
* FULLER shows both authors and dates.
*/
if (!memcmp(line, "author ", 7)) {
if (!prefixcmp(line, "author ")) {
strbuf_grow(sb, linelen + 80);
pp_user_info(pp, "Author", sb, line + 7, encoding);
}
if (!memcmp(line, "committer ", 10) &&
if (!prefixcmp(line, "committer ") &&
(pp->fmt == CMIT_FMT_FULL || pp->fmt == CMIT_FMT_FULLER)) {
strbuf_grow(sb, linelen + 80);
pp_user_info(pp, "Commit", sb, line + 10, encoding);
Expand Down

0 comments on commit 3ab4c54

Please sign in to comment.