git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Eric Sunshine <sunshine@sunshineco.com>
To: git@vger.kernel.org
Cc: Eric Sunshine <sunshine@sunshineco.com>,
	Junio C Hamano <gitster@pobox.com>,
	Stefan Beller <stefanbeller@googlemail.com>
Subject: [PATCH v2 2/9] mailmap: do not lose single-letter names
Date: Mon, 15 Jul 2013 02:54:06 -0400	[thread overview]
Message-ID: <1373871253-96480-3-git-send-email-sunshine@sunshineco.com> (raw)
In-Reply-To: <1373871253-96480-1-git-send-email-sunshine@sunshineco.com>

From: Junio C Hamano <gitster@pobox.com>

In parse_name_and_email() function, there is this line:

	*name = (nstart < nend ? nstart : NULL);

When the function is given a buffer "A <A@example.org> <old@x.z>",
nstart scans from the beginning of the buffer, skipping whitespaces
(there isn't any, so nstart points at the buffer), while nend starts
from one byte before the first '<' and skips whitespaces backwards
and stops at the first non-whitespace (i.e. it hits "A" at the
beginning of the buffer).  nstart == nend in this case for a
single-letter name, and an off-by-one error makes it fail to pick up
the name, which makes the entry equivalent to

	<A@example.org> <old@x.z>

without the name.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
---
 mailmap.c          | 2 +-
 t/t4203-mailmap.sh | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/mailmap.c b/mailmap.c
index 2a7b366..418081e 100644
--- a/mailmap.c
+++ b/mailmap.c
@@ -122,7 +122,7 @@ static char *parse_name_and_email(char *buffer, char **name,
 	while (nend > nstart && isspace(*nend))
 		--nend;
 
-	*name = (nstart < nend ? nstart : NULL);
+	*name = (nstart <= nend ? nstart : NULL);
 	*email = left+1;
 	*(nend+1) = '\0';
 	*right++ = '\0';
diff --git a/t/t4203-mailmap.sh b/t/t4203-mailmap.sh
index 27f8f86..8583724 100755
--- a/t/t4203-mailmap.sh
+++ b/t/t4203-mailmap.sh
@@ -247,7 +247,7 @@ test_expect_success 'cleanup after mailmap.blob tests' '
 	rm -f .mailmap
 '
 
-test_expect_failure 'single-character name' '
+test_expect_success 'single-character name' '
 	echo "     1	A <author@example.com>" >expect &&
 	echo "     1	nick1 <bugs@company.xx>" >>expect &&
 	echo "A <author@example.com>" >.mailmap &&
-- 
1.8.3.2.804.g0da7a53

  parent reply	other threads:[~2013-07-15  6:54 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-15  6:54 [PATCH v2 0/9] mailmap fixes Eric Sunshine
2013-07-15  6:54 ` [PATCH v2 1/9] t4203: demonstrate loss of single-character name in mailmap entry Eric Sunshine
2013-07-15  6:54 ` Eric Sunshine [this message]
2013-07-15  6:54 ` [PATCH v2 3/9] t4203: demonstrate loss of uppercase characters in canonical email Eric Sunshine
2013-07-15  6:54 ` [PATCH v2 4/9] mailmap: do not downcase mailmap entries Eric Sunshine
2013-07-15  6:54 ` [PATCH v2 5/9] mailmap: debug: fix out-of-order fprintf() arguments Eric Sunshine
2013-07-15 15:18   ` Junio C Hamano
2013-07-15  6:54 ` [PATCH v2 6/9] mailmap: debug: fix malformed fprintf() format directive Eric Sunshine
2013-07-15  6:54 ` [PATCH v2 7/9] mailmap: debug: eliminate -Wformat field precision type warning Eric Sunshine
2013-07-15  6:54 ` [PATCH v2 8/9] mailmap: debug: avoid passing NULL to fprintf() '%s' directive Eric Sunshine
2013-07-15  6:54 ` [PATCH v2 9/9] mailmap: style fixes Eric Sunshine
2013-07-15 15:22   ` 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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=1373871253-96480-3-git-send-email-sunshine@sunshineco.com \
    --to=sunshine@sunshineco.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=stefanbeller@googlemail.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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).