mailmap: Fix more bugs which snuck in when I rebased
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
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 */