Git development
 help / color / mirror / Atom feed
From: Kirill Smelkov <kirr@landau.phys.spbu.ru>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: What's cooking in git.git (Jan 2009, #07; Wed, 28)
Date: Sun, 1 Feb 2009 20:45:05 +0300	[thread overview]
Message-ID: <20090201174505.GA14181@roro3.zxlink> (raw)
In-Reply-To: <7vwscej26i.fsf@gitster.siamese.dyndns.org>

On Wed, Jan 28, 2009 at 06:06:45PM -0800, Junio C Hamano wrote:

[...]

> * ks/maint-mailinfo-folded (Tue Jan 13 01:21:04 2009 +0300) 4 commits
>  + mailinfo: tests for RFC2047 examples
>  + mailinfo: add explicit test for mails like '<a.u.thor@example.com>
>    (A U Thor)'
>  + mailinfo: 'From:' header should be unfold as well
>  + mailinfo: correctly handle multiline 'Subject:' header
> 
> I just got tired of waiting and cleaned up the series myself.

Sorry about that. Here is the missing bit (based on master)

--- 8< ---

Subject: [PATCH] mailinfo: cleanup extra spaces for complex 'From:'

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>
---
 builtin-mailinfo.c        |   19 +++++++++++++++----
 t/t5100/info0001          |    2 +-
 t/t5100/rfc2047-info-0004 |    2 +-
 t/t5100/sample.mbox       |    4 ++--
 4 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/builtin-mailinfo.c b/builtin-mailinfo.c
index d4dc23a..2789ccd 100644
--- a/builtin-mailinfo.c
+++ b/builtin-mailinfo.c
@@ -29,6 +29,9 @@ static struct strbuf **p_hdr_data, **s_hdr_data;
 #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;
@@ -109,11 +112,19 @@ static void handle_from(const struct strbuf *from)
 	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 8c05277..f951538 100644
--- a/t/t5100/info0001
+++ b/t/t5100/info0001
@@ -1,4 +1,4 @@
-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
diff --git a/t/t5100/rfc2047-info-0004 b/t/t5100/rfc2047-info-0004
index 0ca7ff0..f67a90a 100644
--- a/t/t5100/rfc2047-info-0004
+++ b/t/t5100/rfc2047-info-0004
@@ -1,4 +1,4 @@
-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 85df55f..c5ad206 100644
--- a/t/t5100/sample.mbox
+++ b/t/t5100/sample.mbox
@@ -2,10 +2,10 @@
 	
     
 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.
 
-- 
1.6.1.284.g5dc13

--- 8< ---


Thanks,
Kirill

  parent reply	other threads:[~2009-02-01 17:45 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-29  2:06 What's cooking in git.git (Jan 2009, #07; Wed, 28) Junio C Hamano
2009-01-29  3:38 ` Jeff King
2009-01-29  3:51 ` Jeff King
2009-01-29  4:02   ` Jeff King
2009-01-29  4:22     ` Junio C Hamano
2009-01-29 11:27   ` Sverre Rabbelier
2009-01-29 11:37     ` Jeff King
2009-01-29 11:40       ` Pieter de Bie
2009-01-29 11:45         ` Sverre Rabbelier
2009-01-29 11:50           ` Jeff King
2009-01-29 12:20             ` Sverre Rabbelier
2009-01-30  4:51               ` Jeff King
2009-01-30 13:18                 ` Johannes Schindelin
2009-01-30 16:26                   ` Jeff King
2009-02-01  1:31                   ` Junio C Hamano
2009-02-12  6:42                     ` Junio C Hamano
2009-02-12 10:51                       ` Sverre Rabbelier
2009-02-12 11:04                       ` Johannes Schindelin
2009-02-12 21:04                         ` Junio C Hamano
2009-02-12 21:51                           ` Johannes Schindelin
2009-02-12 12:32                       ` Jeff King
2009-01-29 11:48         ` Jeff King
2009-01-29 12:04           ` Nico -telmich- Schottelius
2009-01-30  4:59             ` Jeff King
2009-01-29  8:14 ` Charles Bailey
2009-01-29  8:26   ` Junio C Hamano
2009-01-29  9:16     ` Charles Bailey
2009-01-30 16:32       ` Charles Bailey
2009-02-01 17:45 ` Kirill Smelkov [this message]
2009-02-01 21:34   ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090201174505.GA14181@roro3.zxlink \
    --to=kirr@landau.phys.spbu.ru \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox