99
1010#include "common.h"
1111#include "types.h"
12+ #include "buffer.h"
1213
1314/**
1415 * @file git2/mailmap.h
@@ -35,22 +36,20 @@ typedef struct git_mailmap_entry {
3536#define GIT_MAILMAP_ENTRY_INIT {GIT_MAILMAP_ENTRY_VERSION}
3637
3738/**
38- * Create a mailmap object by parsing a mailmap file.
39+ * Create a mailmap object by parsing a mailmap file. Malformed entries in the
40+ * mailmap are ignored.
3941 *
4042 * The mailmap must be freed with 'git_mailmap_free'.
4143 *
4244 * @param out pointer to store the mailmap
43- * @param data raw data buffer to parse
44- * @param size size of the raw data buffer
45- * @return 0 on success
45+ * @param buffer buffer to parse the mailmap from
46+ * @return 0 on success, otherwise an error code
4647 */
47- GIT_EXTERN (int ) git_mailmap_parse (
48- git_mailmap * * out ,
49- const char * data ,
50- size_t size );
48+ GIT_EXTERN (int ) git_mailmap_from_buffer (git_mailmap * * out , git_buf * buffer );
5149
5250/**
53- * Create a mailmap object from the given repository.
51+ * Create a mailmap object from the given repository. Malformed entries in the
52+ * mailmap are ignored.
5453 *
5554 * If the repository is not bare, the repository's working directory root will
5655 * be checked for the '.mailmap' file to be parsed.
@@ -62,20 +61,23 @@ GIT_EXTERN(int) git_mailmap_parse(
6261 *
6362 * @param out pointer to store the mailmap
6463 * @param repo repository to find the .mailmap in
65- * @return 0 on success; GIT_ENOTFOUND if .mailmap could not be found.
64+ * @return 0 on success; GIT_ENOTFOUND if .mailmap could not be found,
65+ * otherwise an error code.
6666 */
67- GIT_EXTERN (int ) git_mailmap_from_repo (
68- git_mailmap * * out ,
69- git_repository * repo );
67+ GIT_EXTERN (int ) git_mailmap_from_repo (git_mailmap * * out , git_repository * repo );
7068
7169/**
72- * Free a mailmap created by 'git_mailmap_parse' or 'git_mailmap_from_repo'.
70+ * Free a mailmap created by 'git_mailmap_from_buffer' or
71+ * 'git_mailmap_from_repo'.
7372 */
7473GIT_EXTERN (void ) git_mailmap_free (git_mailmap * mailmap );
7574
7675/**
7776 * Resolve a name and email to the corresponding real name and email.
7877 *
78+ * The lifetime of the string results is tied to the `mailmap`, `name`, and
79+ * `email` parameters.
80+ *
7981 * @param name_out either 'name', or the real name to use.
8082 * You should NOT free this value.
8183 * @param email_out either 'email' or the real email to use,
@@ -85,11 +87,8 @@ GIT_EXTERN(void) git_mailmap_free(git_mailmap *mailmap);
8587 * @param email the email to resolve.
8688 */
8789GIT_EXTERN (void ) git_mailmap_resolve (
88- const char * * name_out ,
89- const char * * email_out ,
90- const git_mailmap * mailmap ,
91- const char * name ,
92- const char * email );
90+ const char * * name_out , const char * * email_out ,
91+ const git_mailmap * mailmap , const char * name , const char * email );
9392
9493/**
9594 * Get the number of mailmap entries in this mailmap.
@@ -104,8 +103,7 @@ GIT_EXTERN(size_t) git_mailmap_entry_count(const git_mailmap *mailmap);
104103 * @return the mailmap entry at index, or NULL if it cannot be found.
105104 */
106105GIT_EXTERN (const git_mailmap_entry * ) git_mailmap_entry_byindex (
107- const git_mailmap * mailmap ,
108- size_t idx );
106+ const git_mailmap * mailmap , size_t idx );
109107
110108/**
111109 * Lookup a mailmap entry by name/email pair.
@@ -118,9 +116,7 @@ GIT_EXTERN(const git_mailmap_entry *) git_mailmap_entry_byindex(
118116 * @return the corresponding mailmap entry, or NULL if it cannot be found.
119117 */
120118GIT_EXTERN (const git_mailmap_entry * ) git_mailmap_entry_lookup (
121- const git_mailmap * mailmap ,
122- const char * name ,
123- const char * email );
119+ const git_mailmap * mailmap , const char * name , const char * email );
124120
125121/** @} */
126122GIT_END_DECL
0 commit comments