summaryrefslogtreecommitdiff
path: root/builtin/commit.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2012-09-11 18:35:15 (GMT)
committerJunio C Hamano <gitster@pobox.com>2012-09-11 18:35:15 (GMT)
commit13670c5f9c21db55c2d8ab8db9d1da2b5c236ae0 (patch)
treec3e2cbb69a905544b8d8f12683161bc6dc5f7af5 /builtin/commit.c
parent04f426246651cb2c75253939cc065c1069744513 (diff)
parente27ddb64568412b75035a05366c9f091153155ed (diff)
downloadgit-13670c5f9c21db55c2d8ab8db9d1da2b5c236ae0.zip
git-13670c5f9c21db55c2d8ab8db9d1da2b5c236ae0.tar.gz
git-13670c5f9c21db55c2d8ab8db9d1da2b5c236ae0.tar.bz2
Merge branch 'jc/maint-ident-missing-human-name'
"git show --format='%ci'" did not give timestamp correctly for commits created without human readable name on "committer" line. * jc/maint-ident-missing-human-name: split_ident_line(): make best effort when parsing author/committer line
Diffstat (limited to 'builtin/commit.c')
-rw-r--r--builtin/commit.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/builtin/commit.c b/builtin/commit.c
index feb43f4..778cf16 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, '@');