Re: email address handling
Hi,
On Fri, 1 Aug 2008, Andrew Morton wrote:
> I very very frequently copy and paste name+email address out of git
> output and into an MUA. Have done it thousands and thousands of times,
> and it has always worked. I'm sure that many others do the same thing.
$ git log --pretty=email
after this patch:
-- snipsnap --
pretty.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/pretty.c b/pretty.c
index 33ef34a..ba50b54 100644
--- a/pretty.c
+++ b/pretty.c
@@ -140,14 +140,20 @@ void pp_user_info(const char *what, enum cmit_fmt fmt, struct strbuf *sb,
if (fmt == CMIT_FMT_EMAIL) {
char *name_tail = strchr(line, '<');
int display_name_length;
+ int need_quotes;
if (!name_tail)
return;
while (line < name_tail && isspace(name_tail[-1]))
name_tail--;
display_name_length = name_tail - line;
+ need_quotes = !!memchr(line, ',', display_name_length);
filler = "";
strbuf_addstr(sb, "From: ");
+ if (need_quotes)
+ strbuf_addch(sb, '"');
add_rfc2047(sb, line, display_name_length, encoding);
+ if (need_quotes)
+ strbuf_addch(sb, '"');
strbuf_add(sb, name_tail, namelen - display_name_length);
strbuf_addch(sb, '\n');
} else {