Skip to content

Commit ddbca33

Browse files
committed
Merge branch 'jc/maint-ident-missing-human-name' into maint-1.7.11
* jc/maint-ident-missing-human-name: split_ident_line(): make best effort when parsing author/committer line
2 parents dabdc01 + e27ddb6 commit ddbca33

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

builtin/commit.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,20 @@ static void export_one(const char *var, const char *s, const char *e, int hack)
478478
strbuf_release(&buf);
479479
}
480480

481+
static int sane_ident_split(struct ident_split *person)
482+
{
483+
if (!person->name_begin || !person->name_end ||
484+
person->name_begin == person->name_end)
485+
return 0; /* no human readable name */
486+
if (!person->mail_begin || !person->mail_end ||
487+
person->mail_begin == person->mail_end)
488+
return 0; /* no usable mail */
489+
if (!person->date_begin || !person->date_end ||
490+
!person->tz_begin || !person->tz_end)
491+
return 0;
492+
return 1;
493+
}
494+
481495
static void determine_author_info(struct strbuf *author_ident)
482496
{
483497
char *name, *email, *date;
@@ -530,7 +544,8 @@ static void determine_author_info(struct strbuf *author_ident)
530544
if (force_date)
531545
date = force_date;
532546
strbuf_addstr(author_ident, fmt_ident(name, email, date, IDENT_STRICT));
533-
if (!split_ident_line(&author, author_ident->buf, author_ident->len)) {
547+
if (!split_ident_line(&author, author_ident->buf, author_ident->len) &&
548+
sane_ident_split(&author)) {
534549
export_one("GIT_AUTHOR_NAME", author.name_begin, author.name_end, 0);
535550
export_one("GIT_AUTHOR_EMAIL", author.mail_begin, author.mail_end, 0);
536551
export_one("GIT_AUTHOR_DATE", author.date_begin, author.tz_end, '@');

ident.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,10 @@ int split_ident_line(struct ident_split *split, const char *line, int len)
210210
split->name_end = cp + 1;
211211
break;
212212
}
213-
if (!split->name_end)
214-
return status;
213+
if (!split->name_end) {
214+
/* no human readable name */
215+
split->name_end = split->name_begin;
216+
}
215217

216218
for (cp = split->mail_begin; cp < line + len; cp++)
217219
if (*cp == '>') {

0 commit comments

Comments
 (0)