summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c0f6f67)
raw | patch | inline | side by side (parent: c0f6f67)
author | Kirill Smelkov <kirr@landau.phys.spbu.ru> | |
Sun, 1 Feb 2009 17:45:05 +0000 (20:45 +0300) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sun, 1 Feb 2009 20:11:15 +0000 (12:11 -0800) |
currently for cases like
From: A U Thor <a.u.thor@example.com> (Comment)
mailinfo extracts the following 'Author:' field:
Author: A U Thor (Comment)
^^
which has two extra spaces left in there after removed email part.
I think this is wrong so here is a fix.
Signed-off-by: Kirill Smelkov <kirr@landau.phys.spbu.ru>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
From: A U Thor <a.u.thor@example.com> (Comment)
mailinfo extracts the following 'Author:' field:
Author: A U Thor (Comment)
^^
which has two extra spaces left in there after removed email part.
I think this is wrong so here is a fix.
Signed-off-by: Kirill Smelkov <kirr@landau.phys.spbu.ru>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-mailinfo.c | patch | blob | history | |
t/t5100/info0001 | patch | blob | history | |
t/t5100/rfc2047-info-0004 | patch | blob | history | |
t/t5100/sample.mbox | patch | blob | history |
diff --git a/builtin-mailinfo.c b/builtin-mailinfo.c
index d4dc23a36398e33dd3cf6a75dc8fbc58c06b09c4..2789ccdf7dd43a1170a1ca28a3e4d4802422e719 100644 (file)
--- a/builtin-mailinfo.c
+++ b/builtin-mailinfo.c
#define MAX_HDR_PARSED 10
#define MAX_BOUNDARIES 5
+static void cleanup_space(struct strbuf *sb);
+
+
static void get_sane_name(struct strbuf *out, struct strbuf *name, struct strbuf *email)
{
struct strbuf *src = name;
strbuf_add(&email, at, el);
strbuf_remove(&f, at - f.buf, el + (at[el] ? 1 : 0));
- /* The remainder is name. It could be "John Doe <john.doe@xz>"
- * or "john.doe@xz (John Doe)", but we have removed the
- * email part, so trim from both ends, possibly removing
- * the () pair at the end.
+ /* The remainder is name. It could be
+ *
+ * - "John Doe <john.doe@xz>" (a), or
+ * - "john.doe@xz (John Doe)" (b), or
+ * - "John (zzz) Doe <john.doe@xz> (Comment)" (c)
+ *
+ * but we have removed the email part, so
+ *
+ * - remove extra spaces which could stay after email (case 'c'), and
+ * - trim from both ends, possibly removing the () pair at the end
+ * (cases 'a' and 'b').
*/
+ cleanup_space(&f);
strbuf_trim(&f);
if (f.buf[0] == '(' && f.len && f.buf[f.len - 1] == ')') {
strbuf_remove(&f, 0, 1);
diff --git a/t/t5100/info0001 b/t/t5100/info0001
index 8c052777e0d216e84bb8464b1ceaff1bc7721154..f951538acc0152987d0e296ab0ea73b738275bdb 100644 (file)
--- a/t/t5100/info0001
+++ b/t/t5100/info0001
-Author: A U Thor
+Author: A (zzz) U Thor (Comment)
Email: a.u.thor@example.com
Subject: a commit.
Date: Fri, 9 Jun 2006 00:44:16 -0700
index 0ca7ff0529be38f54a474fefc842fcee73bf75b1..f67a90a9749fae52b9061777c63ce6f02201eb84 100644 (file)
-Author: Nathaniel Borenstein (םולש ןב ילטפנ)
+Author: Nathaniel Borenstein (םולש ןב ילטפנ)
Email: nsb@thumper.bellcore.com
Subject: Test of new header generator
diff --git a/t/t5100/sample.mbox b/t/t5100/sample.mbox
index 85df55f2c43c9462f7bf36f0b3acf186b84d64b0..c5ad206b40e1fcf79019cebdfd848d72c17cefcc 100644 (file)
--- a/t/t5100/sample.mbox
+++ b/t/t5100/sample.mbox
From nobody Mon Sep 17 00:00:00 2001
-From: A
+From: A (zzz)
U
Thor
- <a.u.thor@example.com>
+ <a.u.thor@example.com> (Comment)
Date: Fri, 9 Jun 2006 00:44:16 -0700
Subject: [PATCH] a commit.