Merge branch 'jk/commit-date-approxidate'
authorJunio C Hamano <gitster@pobox.com>
Mon, 22 Dec 2014 20:28:14 +0000 (12:28 -0800)
committerJunio C Hamano <gitster@pobox.com>
Mon, 22 Dec 2014 20:28:14 +0000 (12:28 -0800)
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

1  2 
builtin/commit.c
index cda74e9a68f75fe3809a6dfa3901448be88eb7e5,920bb6316b21f486589a3d394f2b8795a6712605..7d90c3591567d10f9a075ec38048b93923f707d4
@@@ -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;