From: Josh Stone <jistone@redhat.com>
To: git@vger.kernel.org
Cc: Josh Stone <jistone@redhat.com>
Subject: [PATCH] blame: Improve parsing for emails with spaces
Date: Thu, 21 Apr 2011 15:07:36 -0700 [thread overview]
Message-ID: <1303423656-32002-1-git-send-email-jistone@redhat.com> (raw)
One of my git repositories has some old commits where the authors
obfuscated their email address as <author at example dot com>. To
handle this, blame needs to look for the leading '<' when scanning
to split the "name <email>", rather then only a space delimiter.
Signed-off-by: Josh Stone <jistone@redhat.com>
---
builtin/blame.c | 2 +-
t/annotate-tests.sh | 12 +++++++++++-
t/t8002-blame.sh | 2 +-
3 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/builtin/blame.c b/builtin/blame.c
index f6b03f7..41525f1 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -1377,7 +1377,7 @@ static void get_ac_line(const char *inbuf, const char *what,
timepos = tmp;
*tmp = 0;
- while (person < tmp && *tmp != ' ')
+ while (person < tmp && !(*tmp == ' ' && tmp[1] == '<'))
tmp--;
if (tmp <= person)
return;
diff --git a/t/annotate-tests.sh b/t/annotate-tests.sh
index d34208c..abb1885 100644
--- a/t/annotate-tests.sh
+++ b/t/annotate-tests.sh
@@ -1,5 +1,5 @@
# This file isn't used as a test script directly, instead it is
-# sourced from t8001-annotate.sh and t8001-blame.sh.
+# sourced from t8001-annotate.sh and t8002-blame.sh.
check_count () {
head=
@@ -124,3 +124,13 @@ test_expect_success \
test_expect_success \
'some edit' \
'check_count A 1 B 1 B1 1 B2 1 "A U Thor" 1 C 1 D 1'
+
+test_expect_success \
+ 'an obfuscated email added' \
+ 'sed -e "1i No robots allowed" < file > file.new &&
+ mv file.new file &&
+ GIT_AUTHOR_NAME="E" GIT_AUTHOR_EMAIL="E at test dot git" git commit -a -m "norobots"'
+
+test_expect_success \
+ 'obfuscated email parsed' \
+ 'check_count A 1 B 1 B1 1 B2 1 "A U Thor" 1 C 1 D 1 E 1'
diff --git a/t/t8002-blame.sh b/t/t8002-blame.sh
index d3a51e1..e2896cf 100755
--- a/t/t8002-blame.sh
+++ b/t/t8002-blame.sh
@@ -8,7 +8,7 @@ PROG='git blame -c'
PROG='git blame -c -e'
test_expect_success 'Blame --show-email works' '
- check_count "<A@test.git>" 1 "<B@test.git>" 1 "<B1@test.git>" 1 "<B2@test.git>" 1 "<author@example.com>" 1 "<C@test.git>" 1 "<D@test.git>" 1
+ check_count "<A@test.git>" 1 "<B@test.git>" 1 "<B1@test.git>" 1 "<B2@test.git>" 1 "<author@example.com>" 1 "<C@test.git>" 1 "<D@test.git>" 1 "<E at test dot git>" 1
'
test_done
--
1.7.4.4
next reply other threads:[~2011-04-21 22:10 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-21 22:07 Josh Stone [this message]
2011-04-29 13:11 ` [PATCH] blame: Improve parsing for emails with spaces Jeff King
2011-04-29 17:59 ` Junio C Hamano
2011-04-29 18:09 ` Junio C Hamano
2011-04-29 18:17 ` Josh Stone
2011-04-29 19:13 ` Jeff King
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=1303423656-32002-1-git-send-email-jistone@redhat.com \
--to=jistone@redhat.com \
--cc=git@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).