From: Junio C Hamano Date: Mon, 22 Dec 2014 20:28:14 +0000 (-0800) Subject: Merge branch 'jk/commit-date-approxidate' X-Git-Tag: v2.3.0-rc0~40 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2df39733e5b07e76ad271c99ff22f5d59a7bf223;p=thirdparty%2Fgit.git Merge branch 'jk/commit-date-approxidate' Recent update to "git commit" broke amending an existing commit with bogus author/committer lines without a valid e-mail address. * jk/commit-date-approxidate: commit: always populate GIT_AUTHOR_* variables commit: loosen ident checks when generating template --- 2df39733e5b07e76ad271c99ff22f5d59a7bf223 diff --cc builtin/commit.c index cda74e9a68,920bb6316b..7d90c35915 --- a/builtin/commit.c +++ b/builtin/commit.c @@@ -532,25 -518,14 +538,11 @@@ static void export_one(const char *var 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 int parse_force_date(const char *in, char *out, int len) +static int parse_force_date(const char *in, struct strbuf *out) { - if (len < 1) - return -1; - *out++ = '@'; - len--; + strbuf_addch(out, '@'); - if (parse_date(in, out, len) < 0) { + if (parse_date(in, out) < 0) { int errors = 0; unsigned long t = approxidate_careful(in, &errors); if (errors) @@@ -623,25 -592,12 +615,15 @@@ static void determine_author_info(struc } strbuf_addstr(author_ident, fmt_ident(name, email, date, IDENT_STRICT)); - 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, '@'); - } - + assert_split_ident(&author, author_ident); + 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, '@'); + free(name); + free(email); + free(date); } - static void split_ident_or_die(struct ident_split *id, const struct strbuf *buf) - { - if (split_ident_line(id, buf->buf, buf->len) || - !sane_ident_split(id)) - die(_("Malformed ident string: '%s'"), buf->buf); - } - static int author_date_is_interesting(void) { return author_message || force_date;