summaryrefslogtreecommitdiff
path: root/commit.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2014-08-27 03:56:55 -0400
committerJunio C Hamano <gitster@pobox.com>2014-08-27 10:31:13 -0700
commitea5517f04b08bdb40eca72888220bd6a90d3cf17 (patch)
tree30f742f01d8d09b067737aba5ff4058a6f51f3ff /commit.c
parent6876618ceaafddba625ed823679d99de0e79d111 (diff)
downloadgit-ea5517f04b08bdb40eca72888220bd6a90d3cf17.tar.gz
record_author_date(): use find_commit_header()
This saves us some manual parsing and makes the code more readable. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'commit.c')
-rw-r--r--commit.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/commit.c b/commit.c
index 4ff8c66f96..9416d842c6 100644
--- a/commit.c
+++ b/commit.c
@@ -584,25 +584,19 @@ define_commit_slab(author_date_slab, unsigned long);
static void record_author_date(struct author_date_slab *author_date,
struct commit *commit)
{
- const char *buf, *line_end, *ident_line;
const char *buffer = get_commit_buffer(commit, NULL);
struct ident_split ident;
+ const char *ident_line;
+ size_t ident_len;
char *date_end;
unsigned long date;
- for (buf = buffer; buf; buf = line_end + 1) {
- line_end = strchrnul(buf, '\n');
- if (!skip_prefix(buf, "author ", &ident_line)) {
- if (!line_end[0] || line_end[1] == '\n')
- goto fail_exit; /* end of header */
- continue;
- }
- if (split_ident_line(&ident,
- ident_line, line_end - ident_line) ||
- !ident.date_begin || !ident.date_end)
- goto fail_exit; /* malformed "author" line */
- break;
- }
+ ident_line = find_commit_header(buffer, "author", &ident_len);
+ if (!ident_line)
+ goto fail_exit; /* no author line */
+ if (split_ident_line(&ident, ident_line, ident_len) ||
+ !ident.date_begin || !ident.date_end)
+ goto fail_exit; /* malformed "author" line */
date = strtoul(ident.date_begin, &date_end, 10);
if (date_end != ident.date_end)