summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2015-06-16 10:40:46 -0400
committerEdward Thomson <ethomson@edwardthomson.com>2015-06-16 10:40:46 -0400
commit5f83758fa35a7942457d676e41240dbfbda598b5 (patch)
tree9b5afeebd65f352517f48ba2622ecce899aef562
parent86faea5fce37987aa05cb8aa9f525fa4e90dd6ca (diff)
parent65d69fe854ceeb65eeaed7f38a1f4a4771532b9d (diff)
downloadlibgit2-5f83758fa35a7942457d676e41240dbfbda598b5.tar.gz
Merge pull request #3209 from libgit2/cmn/double-author
commit: ignore multiple author fields
-rw-r--r--src/commit.c10
-rw-r--r--tests/commit/parse.c7
2 files changed, 17 insertions, 0 deletions
diff --git a/src/commit.c b/src/commit.c
index 84f24c6cf..ce13bdb85 100644
--- a/src/commit.c
+++ b/src/commit.c
@@ -309,6 +309,7 @@ int git_commit__parse(void *_commit, git_odb_object *odb_obj)
const char *buffer_end = buffer_start + git_odb_object_size(odb_obj);
git_oid parent_id;
size_t header_len;
+ git_signature dummy_sig;
buffer = buffer_start;
@@ -337,6 +338,15 @@ int git_commit__parse(void *_commit, git_odb_object *odb_obj)
if (git_signature__parse(commit->author, &buffer, buffer_end, "author ", '\n') < 0)
return -1;
+ /* Some tools create multiple author fields, ignore the extra ones */
+ while ((size_t)(buffer_end - buffer) >= strlen("author ") && !git__prefixcmp(buffer, "author ")) {
+ if (git_signature__parse(&dummy_sig, &buffer, buffer_end, "author ", '\n') < 0)
+ return -1;
+
+ git__free(dummy_sig.name);
+ git__free(dummy_sig.email);
+ }
+
/* Always parse the committer; we need the commit time */
commit->committer = git__malloc(sizeof(git_signature));
GITERR_CHECK_ALLOC(commit->committer);
diff --git a/tests/commit/parse.c b/tests/commit/parse.c
index 41e162440..fa079f470 100644
--- a/tests/commit/parse.c
+++ b/tests/commit/parse.c
@@ -262,6 +262,13 @@ gpgsig -----BEGIN PGP SIGNATURE-----\n\
-----END PGP SIGNATURE-----\n\
\n\
a simple commit which works\n",
+/* some tools create two author entries */
+"tree 1810dff58d8a660512d4832e740f692884338ccd\n\
+author Vicent Marti <tanoku@gmail.com> 1273848544 +0200\n\
+author Helpful Coworker <helpful@coworker> 1273848544 +0200\n\
+committer Vicent Marti <tanoku@gmail.com> 1273848544 +0200\n\
+\n\
+a simple commit which works",
};
static int parse_commit(git_commit **out, const char *buffer)