diff options
author | Junio C Hamano <gitster@pobox.com> | 2012-08-31 14:54:18 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2012-08-31 14:54:18 -0700 |
commit | e27ddb64568412b75035a05366c9f091153155ed (patch) | |
tree | 091ab1745b6e1e81ac5fba6631c4106d24b966e5 /builtin/commit.c | |
parent | Prepare for 1.7.11.6 (diff) | |
download | tgif-e27ddb64568412b75035a05366c9f091153155ed.tar.xz |
split_ident_line(): make best effort when parsing author/committer line
Commits made by ancient version of Git allowed committer without
human readable name, like this (00213b17c in the kernel history):
tree 6947dba41f8b0e7fe7bccd41a4840d6de6a27079
parent 352dd1df32e672be4cff71132eb9c06a257872fe
author Petr Baudis <pasky@ucw.cz> 1135223044 +0100
committer <sam@mars.ravnborg.org> 1136151043 +0100
kconfig: Remove support for lxdialog --checklist
...
Signed-off-by: Petr Baudis <pasky@suse.cz>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
When fed such a commit, --format='%ci' fails to parse it, and gives
back an empty string. Update the split_ident_line() to be a bit
more lenient when parsing, but make sure the caller that wants to
pick up sane value from its return value does its own validation.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/commit.c')
-rw-r--r-- | builtin/commit.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/builtin/commit.c b/builtin/commit.c index 20cef95d60..62028e7b44 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -478,6 +478,20 @@ static void export_one(const char *var, const char *s, const char *e, int hack) 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) { char *name, *email, *date; @@ -530,7 +544,8 @@ static void determine_author_info(struct strbuf *author_ident) if (force_date) date = force_date; 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_EMAIL", author.mail_begin, author.mail_end, 0); export_one("GIT_AUTHOR_DATE", author.date_begin, author.tz_end, '@'); |