@@ -522,6 +522,12 @@ static int is_a_merge(const struct commit *current_head)
522522 return !!(current_head -> parents && current_head -> parents -> next );
523523}
524524
525+ static void assert_split_ident (struct ident_split * id , const struct strbuf * buf )
526+ {
527+ if (split_ident_line (id , buf -> buf , buf -> len ) || !id -> date_begin )
528+ die ("BUG: unable to parse our own ident: %s" , buf -> buf );
529+ }
530+
525531static void export_one (const char * var , const char * s , const char * e , int hack )
526532{
527533 struct strbuf buf = STRBUF_INIT ;
@@ -532,20 +538,6 @@ static void export_one(const char *var, const char *s, const char *e, int hack)
532538 strbuf_release (& buf );
533539}
534540
535- static int sane_ident_split (struct ident_split * person )
536- {
537- if (!person -> name_begin || !person -> name_end ||
538- person -> name_begin == person -> name_end )
539- return 0 ; /* no human readable name */
540- if (!person -> mail_begin || !person -> mail_end ||
541- person -> mail_begin == person -> mail_end )
542- return 0 ; /* no usable mail */
543- if (!person -> date_begin || !person -> date_end ||
544- !person -> tz_begin || !person -> tz_end )
545- return 0 ;
546- return 1 ;
547- }
548-
549541static int parse_force_date (const char * in , struct strbuf * out )
550542{
551543 strbuf_addch (out , '@' );
@@ -623,25 +615,15 @@ static void determine_author_info(struct strbuf *author_ident)
623615 }
624616
625617 strbuf_addstr (author_ident , fmt_ident (name , email , date , IDENT_STRICT ));
626- if (!split_ident_line (& author , author_ident -> buf , author_ident -> len ) &&
627- sane_ident_split (& author )) {
628- export_one ("GIT_AUTHOR_NAME" , author .name_begin , author .name_end , 0 );
629- export_one ("GIT_AUTHOR_EMAIL" , author .mail_begin , author .mail_end , 0 );
630- export_one ("GIT_AUTHOR_DATE" , author .date_begin , author .tz_end , '@' );
631- }
632-
618+ assert_split_ident (& author , author_ident );
619+ export_one ("GIT_AUTHOR_NAME" , author .name_begin , author .name_end , 0 );
620+ export_one ("GIT_AUTHOR_EMAIL" , author .mail_begin , author .mail_end , 0 );
621+ export_one ("GIT_AUTHOR_DATE" , author .date_begin , author .tz_end , '@' );
633622 free (name );
634623 free (email );
635624 free (date );
636625}
637626
638- static void split_ident_or_die (struct ident_split * id , const struct strbuf * buf )
639- {
640- if (split_ident_line (id , buf -> buf , buf -> len ) ||
641- !sane_ident_split (id ))
642- die (_ ("Malformed ident string: '%s'" ), buf -> buf );
643- }
644-
645627static int author_date_is_interesting (void )
646628{
647629 return author_message || force_date ;
@@ -856,8 +838,14 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
856838 status_printf_ln (s , GIT_COLOR_NORMAL ,
857839 "%s" , only_include_assumed );
858840
859- split_ident_or_die (& ai , author_ident );
860- split_ident_or_die (& ci , & committer_ident );
841+ /*
842+ * These should never fail because they come from our own
843+ * fmt_ident. They may fail the sane_ident test, but we know
844+ * that the name and mail pointers will at least be valid,
845+ * which is enough for our tests and printing here.
846+ */
847+ assert_split_ident (& ai , author_ident );
848+ assert_split_ident (& ci , & committer_ident );
861849
862850 if (ident_cmp (& ai , & ci ))
863851 status_printf_ln (s , GIT_COLOR_NORMAL ,
0 commit comments