Commit 23e38fd3 by Edward Thomson

mailmap: use GIT_ASSERT

parent 79b0c8c8
......@@ -43,7 +43,8 @@ static int mailmap_entry_cmp(const void *a_raw, const void *b_raw)
const git_mailmap_entry *b = (const git_mailmap_entry *)b_raw;
int cmp;
assert(a && b && a->replace_email && b->replace_email);
GIT_ASSERT_ARG(a && a->replace_email);
GIT_ASSERT_ARG(b && b->replace_email);
cmp = git__strcmp(a->replace_email, b->replace_email);
if (cmp)
......@@ -185,7 +186,8 @@ static int mailmap_add_entry_unterminated(
git_mailmap_entry *entry = git__calloc(1, sizeof(git_mailmap_entry));
GIT_ERROR_CHECK_ALLOC(entry);
assert(mm && replace_email && *replace_email);
GIT_ASSERT_ARG(mm);
GIT_ASSERT_ARG(replace_email && *replace_email);
if (real_name_size > 0) {
entry->real_name = git__substrdup(real_name, real_name_size);
......@@ -290,7 +292,8 @@ static int mailmap_add_blob(
git_buf content = GIT_BUF_INIT;
int error;
assert(mm && repo);
GIT_ASSERT_ARG(mm);
GIT_ASSERT_ARG(repo);
error = git_revparse_single(&object, repo, rev);
if (error < 0)
......@@ -350,8 +353,6 @@ static void mailmap_add_from_repository(git_mailmap *mm, git_repository *repo)
const char *rev = NULL;
const char *path = NULL;
assert(mm && repo);
/* If we're in a bare repo, default blob to 'HEAD:.mailmap' */
if (repo->is_bare)
rev = MM_BLOB_DEFAULT;
......@@ -389,9 +390,14 @@ static void mailmap_add_from_repository(git_mailmap *mm, git_repository *repo)
int git_mailmap_from_repository(git_mailmap **out, git_repository *repo)
{
int error = git_mailmap_new(out);
if (error < 0)
int error;
GIT_ASSERT_ARG(out);
GIT_ASSERT_ARG(repo);
if ((error = git_mailmap_new(out)) < 0)
return error;
mailmap_add_from_repository(*out, repo);
return 0;
}
......@@ -408,7 +414,7 @@ const git_mailmap_entry *git_mailmap_entry_lookup(
git_mailmap_entry needle = { NULL };
needle.replace_email = (char *)email;
assert(email);
GIT_ASSERT_ARG_WITH_RETVAL(email, NULL);
if (!mm)
return NULL;
......@@ -431,7 +437,8 @@ const git_mailmap_entry *git_mailmap_entry_lookup(
if (git__strcmp(entry->replace_email, email))
break; /* it's a different email, so we're done looking */
assert(entry->replace_name); /* should be specific */
/* should be specific */
GIT_ASSERT_WITH_RETVAL(entry->replace_name, NULL);
if (!name || !git__strcmp(entry->replace_name, name))
return entry;
}
......@@ -447,7 +454,9 @@ int git_mailmap_resolve(
const char *name, const char *email)
{
const git_mailmap_entry *entry = NULL;
assert(name && email);
GIT_ASSERT(name);
GIT_ASSERT(email);
*real_name = name;
*real_email = email;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment