From: Junio C Hamano Date: Thu, 7 Nov 2013 22:34:51 +0000 (-0800) Subject: Merge branch 'jk/split-broken-ident' into maint X-Git-Tag: v1.8.4.3~12 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/0ceb7537c11f60d15786fa12b7d9602c68ee1b29?hp=-c Merge branch 'jk/split-broken-ident' into maint The fall-back parsing of commit objects with broken author or committer lines were less robust than ideal in picking up the timestamps. * jk/split-broken-ident: split_ident: parse timestamp from end of line --- 0ceb7537c11f60d15786fa12b7d9602c68ee1b29 diff --combined ident.c index b29f81f83a,7d1c79c2f9..1d9b6e770d --- a/ident.c +++ b/ident.c @@@ -233,7 -233,21 +233,21 @@@ int split_ident_line(struct ident_spli if (!split->mail_end) return status; - for (cp = split->mail_end + 1; cp < line + len && isspace(*cp); cp++) + /* + * Look from the end-of-line to find the trailing ">" of the mail + * address, even though we should already know it as split->mail_end. + * This can help in cases of broken idents with an extra ">" somewhere + * in the email address. Note that we are assuming the timestamp will + * never have a ">" in it. + * + * Note that we will always find some ">" before going off the front of + * the string, because will always hit the split->mail_end closing + * bracket. + */ + for (cp = line + len - 1; *cp != '>'; cp--) + ; + + for (cp = cp + 1; cp < line + len && isspace(*cp); cp++) ; if (line + len <= cp) goto person_only; @@@ -402,32 -416,3 +416,32 @@@ int git_ident_config(const char *var, c return 0; } + +static int buf_cmp(const char *a_begin, const char *a_end, + const char *b_begin, const char *b_end) +{ + int a_len = a_end - a_begin; + int b_len = b_end - b_begin; + int min = a_len < b_len ? a_len : b_len; + int cmp; + + cmp = memcmp(a_begin, b_begin, min); + if (cmp) + return cmp; + + return a_len - b_len; +} + +int ident_cmp(const struct ident_split *a, + const struct ident_split *b) +{ + int cmp; + + cmp = buf_cmp(a->mail_begin, a->mail_end, + b->mail_begin, b->mail_end); + if (cmp) + return cmp; + + return buf_cmp(a->name_begin, a->name_end, + b->name_begin, b->name_end); +}