Skip to content

Commit 0d4ede9

Browse files
bookgitster
authored andcommitted
mailinfo: better parse email adresses containg parentheses
When using git-rebase, author fields containing a ')' at the last position had the close-parens character removed; the removal should be done only when it is of this form: user@host (User Name) i.e. the remainder after stripping the e-mail address part is enclosed in a parentheses pair as a whole, not for addresses like this: User Name (me) <user@host> Signed-off-by: Philippe Bruhat (BooK) <book@cpan.org> Acked-by: Lukas Sandström <lukass@etek.chalmers.se> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 75e1645 commit 0d4ede9

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

builtin-mailinfo.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,10 @@ static void handle_from(const struct strbuf *from)
115115
* the () pair at the end.
116116
*/
117117
strbuf_trim(&f);
118-
if (f.buf[0] == '(')
119-
strbuf_remove(&name, 0, 1);
120-
if (f.len && f.buf[f.len - 1] == ')')
118+
if (f.buf[0] == '(' && f.len && f.buf[f.len - 1] == ')') {
119+
strbuf_remove(&f, 0, 1);
121120
strbuf_setlen(&f, f.len - 1);
121+
}
122122

123123
get_sane_name(&name, &f, &email);
124124
strbuf_release(&f);

0 commit comments

Comments
 (0)