Skip to content

Commit d91d296

Browse files
committed
mailmap: Hide EEXISTS to simplify git_mailmap_add_entry callers
1 parent c1a85ae commit d91d296

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

include/git2/mailmap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ GIT_EXTERN(void) git_mailmap_free(git_mailmap *mm);
4747
* @param real_email the real email to use, or NULL
4848
* @param replace_name the name to replace, or NULL
4949
* @param replace_email the email to replace
50-
* @return 0 if it was added, EEXISTS if it replaced an entry, or an error code
50+
* @return 0 on success, or an error code
5151
*/
5252
GIT_EXTERN(int) git_mailmap_add_entry(
5353
git_mailmap *mm, const char *real_name, const char *real_email,

src/mailmap.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,9 @@ static int mailmap_add_entry_unterminated(
203203
GITERR_CHECK_ALLOC(entry->replace_email);
204204

205205
error = git_vector_insert_sorted(&mm->entries, entry, mailmap_entry_replace);
206-
if (error < 0 && error != GIT_EEXISTS)
206+
if (error == GIT_EEXISTS)
207+
error = GIT_OK;
208+
else if (error < 0)
207209
mailmap_entry_free(entry);
208210

209211
return error;
@@ -256,7 +258,7 @@ int git_mailmap_add_buffer(git_mailmap *mm, const char *buf, size_t len)
256258
error = mailmap_add_entry_unterminated(
257259
mm, real_name.ptr, real_name.size, real_email.ptr, real_email.size,
258260
replace_name.ptr, replace_name.size, replace_email.ptr, replace_email.size);
259-
if (error < 0 && error != GIT_EEXISTS)
261+
if (error < 0)
260262
goto cleanup;
261263

262264
error = 0;

0 commit comments

Comments
 (0)