summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ec014ea)
raw | patch | inline | side by side (parent: ec014ea)
author | Josh Stone <jistone@redhat.com> | |
Thu, 21 Apr 2011 22:07:36 +0000 (15:07 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Fri, 29 Apr 2011 18:09:42 +0000 (11:09 -0700) |
The names and e-mails are sanitized by fmt_ident() when creating commits,
so that they do not contain "<" nor ">", and the "committer" and "author"
lines in the commit object will always be in the form:
("author" | "committer") name SP "<" email ">" SP timestamp SP zone
When parsing the email part out, the current code looks for SP starting
from the end of the email part, but the author could obfuscate the address
as "author at example dot com".
We should instead look for SP followed by "<", to match the logic of the
side that formats these lines.
Signed-off-by: Josh Stone <jistone@redhat.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
so that they do not contain "<" nor ">", and the "committer" and "author"
lines in the commit object will always be in the form:
("author" | "committer") name SP "<" email ">" SP timestamp SP zone
When parsing the email part out, the current code looks for SP starting
from the end of the email part, but the author could obfuscate the address
as "author at example dot com".
We should instead look for SP followed by "<", to match the logic of the
side that formats these lines.
Signed-off-by: Josh Stone <jistone@redhat.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/blame.c | patch | blob | history | |
t/annotate-tests.sh | patch | blob | history | |
t/t8002-blame.sh | patch | blob | history |
diff --git a/builtin/blame.c b/builtin/blame.c
index f6b03f750a0b69ef835caa0a2e4988f9a08abb85..41525f1ea1fff29fae56d7c8b3db41db7d928fd5 100644 (file)
--- a/builtin/blame.c
+++ b/builtin/blame.c
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 d34208cc27623a6105f6b12f863c648429d2d34d..abb18859574a382e41c41dc27835dd9727f45e9e 100644 (file)
--- a/t/annotate-tests.sh
+++ b/t/annotate-tests.sh
# 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=
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 d3a51e12698bed50d4eef1474e75dbfd0be0d034..e2896cffc17c519d208c26f215e4605d85edb918 100755 (executable)
--- a/t/t8002-blame.sh
+++ b/t/t8002-blame.sh
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