summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e49ca97)
raw | patch | inline | side by side (parent: e49ca97)
author | David Reiss <dreiss@facebook.com> | |
Tue, 22 Dec 2009 18:51:41 +0000 (10:51 -0800) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Tue, 22 Dec 2009 19:51:17 +0000 (11:51 -0800) |
The human-readable author and committer name can be missing from
commits imported from foreign SCM interfaces. Make sure we parse
the "author" and "committer" line a bit more leniently and avoid
segfaulting by assuming the name always exists.
Signed-off-by: David Reiss <dreiss@facebook.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
commits imported from foreign SCM interfaces. Make sure we parse
the "author" and "committer" line a bit more leniently and avoid
segfaulting by assuming the name always exists.
Signed-off-by: David Reiss <dreiss@facebook.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-blame.c | patch | blob | history | |
t/t8003-blame.sh | patch | blob | history |
diff --git a/builtin-blame.c b/builtin-blame.c
index dd16b2229763addfba8f02f3d9b3c42dcb995935..98e818ce6a63b352182b428b49464596d37a0617 100644 (file)
--- a/builtin-blame.c
+++ b/builtin-blame.c
error_out:
/* Ugh */
*tz = "(unknown)";
+ strcpy(person, *tz);
strcpy(mail, *tz);
*time = 0;
return;
tmp = person;
tmp += len;
*tmp = 0;
- while (*tmp != ' ')
+ while (person < tmp && *tmp != ' ')
tmp--;
+ if (tmp <= person)
+ goto error_out;
*tz = tmp+1;
tzlen = (person+len)-(tmp+1);
*tmp = 0;
- while (*tmp != ' ')
+ while (person < tmp && *tmp != ' ')
tmp--;
+ if (tmp <= person)
+ goto error_out;
*time = strtoul(tmp, NULL, 10);
timepos = tmp;
*tmp = 0;
- while (*tmp != ' ')
+ while (person < tmp && *tmp != ' ')
tmp--;
+ if (tmp <= person)
+ return;
mailpos = tmp + 1;
*tmp = 0;
maillen = timepos - tmp;
diff --git a/t/t8003-blame.sh b/t/t8003-blame.sh
index 13c25f1d528ca1ec90575e42e0393accff5d8f35..ad834f200ac0d6ecf532374311d896557a9b941d 100755 (executable)
--- a/t/t8003-blame.sh
+++ b/t/t8003-blame.sh
git blame HEAD^.. -- path
'
+test_expect_success 'blame to a commit with no author name' '
+ TREE=`git rev-parse HEAD:`
+ cat >badcommit <<EOF
+tree $TREE
+author <noname> 1234567890 +0000
+committer David Reiss <dreiss@facebook.com> 1234567890 +0000
+
+some message
+EOF
+ COMMIT=`git hash-object -t commit -w badcommit`
+ git --no-pager blame $COMMIT -- uno >/dev/null
+'
+
test_done