mirror of
https://github.com/git/git.git
synced 2025-03-31 12:54:09 +00:00
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
This commit is contained in:
commit
ddbca33ca7
@ -478,6 +478,20 @@ static void export_one(const char *var, const char *s, const char *e, int hack)
|
|||||||
strbuf_release(&buf);
|
strbuf_release(&buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int sane_ident_split(struct ident_split *person)
|
||||||
|
{
|
||||||
|
if (!person->name_begin || !person->name_end ||
|
||||||
|
person->name_begin == person->name_end)
|
||||||
|
return 0; /* no human readable name */
|
||||||
|
if (!person->mail_begin || !person->mail_end ||
|
||||||
|
person->mail_begin == person->mail_end)
|
||||||
|
return 0; /* no usable mail */
|
||||||
|
if (!person->date_begin || !person->date_end ||
|
||||||
|
!person->tz_begin || !person->tz_end)
|
||||||
|
return 0;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
static void determine_author_info(struct strbuf *author_ident)
|
static void determine_author_info(struct strbuf *author_ident)
|
||||||
{
|
{
|
||||||
char *name, *email, *date;
|
char *name, *email, *date;
|
||||||
@ -530,7 +544,8 @@ static void determine_author_info(struct strbuf *author_ident)
|
|||||||
if (force_date)
|
if (force_date)
|
||||||
date = force_date;
|
date = force_date;
|
||||||
strbuf_addstr(author_ident, fmt_ident(name, email, date, IDENT_STRICT));
|
strbuf_addstr(author_ident, fmt_ident(name, email, date, IDENT_STRICT));
|
||||||
if (!split_ident_line(&author, author_ident->buf, author_ident->len)) {
|
if (!split_ident_line(&author, author_ident->buf, author_ident->len) &&
|
||||||
|
sane_ident_split(&author)) {
|
||||||
export_one("GIT_AUTHOR_NAME", author.name_begin, author.name_end, 0);
|
export_one("GIT_AUTHOR_NAME", author.name_begin, author.name_end, 0);
|
||||||
export_one("GIT_AUTHOR_EMAIL", author.mail_begin, author.mail_end, 0);
|
export_one("GIT_AUTHOR_EMAIL", author.mail_begin, author.mail_end, 0);
|
||||||
export_one("GIT_AUTHOR_DATE", author.date_begin, author.tz_end, '@');
|
export_one("GIT_AUTHOR_DATE", author.date_begin, author.tz_end, '@');
|
||||||
|
6
ident.c
6
ident.c
@ -210,8 +210,10 @@ int split_ident_line(struct ident_split *split, const char *line, int len)
|
|||||||
split->name_end = cp + 1;
|
split->name_end = cp + 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!split->name_end)
|
if (!split->name_end) {
|
||||||
return status;
|
/* no human readable name */
|
||||||
|
split->name_end = split->name_begin;
|
||||||
|
}
|
||||||
|
|
||||||
for (cp = split->mail_begin; cp < line + len; cp++)
|
for (cp = split->mail_begin; cp < line + len; cp++)
|
||||||
if (*cp == '>') {
|
if (*cp == '>') {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user