Commit 4ff44be8ce36b345340eea962d9df8a595c1c0bf

Nika Layzell 2018-03-17T18:24:15

mailmap: Fix more bugs which snuck in when I rebased

diff --git a/include/git2/mailmap.h b/include/git2/mailmap.h
index a80ecb9..0c722b5 100644
--- a/include/git2/mailmap.h
+++ b/include/git2/mailmap.h
@@ -22,14 +22,14 @@ GIT_BEGIN_DECL
 /**
  * A single entry parsed from a mailmap.
  */
-struct git_mailmap_entry {
+typedef struct git_mailmap_entry {
 	unsigned int version;
 
 	const char *real_name; /**< the real name (may be NULL) */
 	const char *real_email; /**< the real email (may be NULL) */
 	const char *replace_name; /**< the name to replace (may be NULL) */
 	const char *replace_email; /**< the email to replace */
-};
+} git_mailmap_entry;
 
 #define GIT_MAILMAP_ENTRY_VERSION 1
 #define GIT_MAILMAP_ENTRY_INIT {GIT_MAILMAP_ENTRY_VERSION}
diff --git a/src/blame.c b/src/blame.c
index 967530b..0624bf4 100644
--- a/src/blame.c
+++ b/src/blame.c
@@ -14,6 +14,7 @@
 #include "git2/diff.h"
 #include "git2/blob.h"
 #include "git2/signature.h"
+#include "git2/mailmap.h"
 #include "util.h"
 #include "repository.h"
 #include "blame_git.h"
diff --git a/src/mailmap.c b/src/mailmap.c
index aaf5446..c0da98d 100644
--- a/src/mailmap.c
+++ b/src/mailmap.c
@@ -215,7 +215,7 @@ int git_mailmap_parse(
 
 cleanup:
 	git__free(entry);
-	if (error < 0)
+	if (error < 0) {
 		git_mailmap_free(*mailmap);
 		*mailmap = NULL;
 	}
@@ -317,7 +317,7 @@ static int git_mailmap_from_bare_repo(
 
 	error = git_object_lookup_bypath(
 		(git_object **) &blob,
-		treeish,
+		tree,
 		".mailmap",
 		GIT_OBJ_BLOB);
 	if (error < 0)
diff --git a/tests/mailmap/basic.c b/tests/mailmap/basic.c
index b507407..10fc30b 100644
--- a/tests/mailmap/basic.c
+++ b/tests/mailmap/basic.c
@@ -15,7 +15,7 @@ const char TEST_MAILMAP[] =
 
 void test_mailmap_basic__initialize(void)
 {
-	cl_git_pass(git_mailmap_parse(&mailmap, TEST_MAILMAP, sizeof(TEST_MAILMAP)));
+	cl_git_pass(git_mailmap_parse(&mailmap, TEST_MAILMAP, sizeof(TEST_MAILMAP) - 1));
 }
 
 void test_mailmap_basic__cleanup(void)
@@ -28,7 +28,7 @@ void test_mailmap_basic__cleanup(void)
 
 void test_mailmap_basic__entry(void)
 {
-	git_mailmap_entry* entry;
+	const git_mailmap_entry* entry;
 
 	cl_assert(git_mailmap_entry_count(mailmap) == 4);
 
@@ -43,7 +43,7 @@ void test_mailmap_basic__entry(void)
 
 void test_mailmap_basic__lookup_not_found(void)
 {
-	git_mailmap_entry* entry = git_mailmap_entry_lookup(
+	const git_mailmap_entry* entry = git_mailmap_entry_lookup(
 		mailmap,
 		"Whoever",
 		"doesnotexist@fo.com");
@@ -52,7 +52,7 @@ void test_mailmap_basic__lookup_not_found(void)
 
 void test_mailmap_basic__lookup(void)
 {
-	git_mailmap_entry* entry = git_mailmap_entry_lookup(
+	const git_mailmap_entry* entry = git_mailmap_entry_lookup(
 		mailmap,
 		"Typoed the name once",
 		"foo@baz.com");
diff --git a/tests/mailmap/blame.c b/tests/mailmap/blame.c
index 2dd3095..45e9812 100644
--- a/tests/mailmap/blame.c
+++ b/tests/mailmap/blame.c
@@ -6,7 +6,6 @@
 
 static git_repository *g_repo;
 static git_blame *g_blame;
-static git_mailmap *g_mailmap;
 
 void test_mailmap_blame__initialize(void)
 {
diff --git a/tests/mailmap/parsing.c b/tests/mailmap/parsing.c
index 3fda25f..a81f2f9 100644
--- a/tests/mailmap/parsing.c
+++ b/tests/mailmap/parsing.c
@@ -24,7 +24,7 @@ void test_mailmap_parsing__cleanup(void)
 static void check_mailmap_entries(
 	const git_mailmap *mailmap, const mailmap_entry *entries, size_t entries_size)
 {
-	const mailmap_entry *parsed = NULL;
+	const git_mailmap_entry *parsed = NULL;
 	size_t idx = 0;
 
 	/* Check that the parsed entries match */