Skip to content

Commit

Permalink
blame: handle broken commit headers gracefully
Browse files Browse the repository at this point in the history
split_ident_line() can leave us with the pointers date_begin, date_end,
tz_begin and tz_end all set to NULL.  Check them before use and supply
the same fallback values as in the case of a negative return code from
split_ident_line().

The "(unknown)" is not actually shown in the output, though, because it
will be converted to a number (zero) eventually.

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
René Scharfe authored and Junio C Hamano committed Apr 17, 2013
1 parent 9dbe7c3 commit de5abe9
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions builtin/blame.c
Original file line number Diff line number Diff line change
Expand Up @@ -1375,10 +1375,15 @@ static void get_ac_line(const char *inbuf, const char *what,
maillen = ident.mail_end - ident.mail_begin;
mailbuf = ident.mail_begin;

*time = strtoul(ident.date_begin, NULL, 10);
if (ident.date_begin && ident.date_end)
*time = strtoul(ident.date_begin, NULL, 10);
else
*time = 0;

len = ident.tz_end - ident.tz_begin;
strbuf_add(tz, ident.tz_begin, len);
if (ident.tz_begin && ident.tz_end)
strbuf_add(tz, ident.tz_begin, ident.tz_end - ident.tz_begin);
else
strbuf_addstr(tz, "(unknown)");

/*
* Now, convert both name and e-mail using mailmap
Expand Down

0 comments on commit de5abe9

Please sign in to comment.