@@ -522,6 +522,12 @@ static int is_a_merge(const struct commit *current_head)
522
522
return !!(current_head -> parents && current_head -> parents -> next );
523
523
}
524
524
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
+
525
531
static void export_one (const char * var , const char * s , const char * e , int hack )
526
532
{
527
533
struct strbuf buf = STRBUF_INIT ;
@@ -532,20 +538,6 @@ static void export_one(const char *var, const char *s, const char *e, int hack)
532
538
strbuf_release (& buf );
533
539
}
534
540
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
-
549
541
static int parse_force_date (const char * in , struct strbuf * out )
550
542
{
551
543
strbuf_addch (out , '@' );
@@ -623,25 +615,15 @@ static void determine_author_info(struct strbuf *author_ident)
623
615
}
624
616
625
617
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 , '@' );
633
622
free (name );
634
623
free (email );
635
624
free (date );
636
625
}
637
626
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
-
645
627
static int author_date_is_interesting (void )
646
628
{
647
629
return author_message || force_date ;
@@ -856,8 +838,14 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
856
838
status_printf_ln (s , GIT_COLOR_NORMAL ,
857
839
"%s" , only_include_assumed );
858
840
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 );
861
849
862
850
if (ident_cmp (& ai , & ci ))
863
851
status_printf_ln (s , GIT_COLOR_NORMAL ,
0 commit comments