|
4 | 4 | * This file is part of libgit2, distributed under the GNU GPL v2 with |
5 | 5 | * a Linking Exception. For full terms see the included COPYING file. |
6 | 6 | */ |
7 | | -#ifndef INCLUDE_mailmap_h__ |
8 | | -#define INCLUDE_mailmap_h__ |
| 7 | +#ifndef INCLUDE_git_mailmap_h__ |
| 8 | +#define INCLUDE_git_mailmap_h__ |
9 | 9 |
|
10 | 10 | #include "common.h" |
11 | | -#include "repository.h" |
| 11 | +#include "tree.h" |
12 | 12 |
|
13 | 13 | /** |
14 | 14 | * @file git2/mailmap.h |
15 | | - * @brief Mailmap access subroutines. |
16 | | - * @defgroup git_rebase Git merge routines |
| 15 | + * @brief Mailmap parsing routines |
| 16 | + * @defgroup git_mailmap Git mailmap routines |
17 | 17 | * @ingroup Git |
18 | 18 | * @{ |
19 | 19 | */ |
20 | 20 | GIT_BEGIN_DECL |
21 | 21 |
|
22 | 22 | typedef struct git_mailmap git_mailmap; |
23 | 23 |
|
24 | | -struct git_mailmap_entry { |
25 | | - const char* name; |
26 | | - const char* email; |
27 | | -}; |
| 24 | +/** |
| 25 | + * A single entry parsed from a mailmap. |
| 26 | + */ |
| 27 | +typedef struct git_mailmap_entry { |
| 28 | + const char *real_name; /**< the real name (may be NULL) */ |
| 29 | + const char *real_email; /**< the real email (may be NULL) */ |
| 30 | + const char *replace_name; /**< the name to replace (may be NULL) */ |
| 31 | + const char *replace_email; /**< the email to replace */ |
| 32 | +} git_mailmap_entry; |
| 33 | + |
| 34 | +/** |
| 35 | + * Create a mailmap object by parsing a mailmap file. |
| 36 | + * |
| 37 | + * The mailmap must be freed with 'git_mailmap_free'. |
| 38 | + * |
| 39 | + * @param out Pointer to store the mailmap |
| 40 | + * @param data raw data buffer to parse |
| 41 | + * @param size size of the raw data buffer |
| 42 | + * @return 0 on success |
| 43 | + */ |
| 44 | +GIT_EXTERN(int) git_mailmap_parse( |
| 45 | + git_mailmap **out, |
| 46 | + const char *data, |
| 47 | + size_t size); |
| 48 | + |
| 49 | +/** |
| 50 | + * Create a mailmap object by parsing the ".mailmap" file in the tree root. |
| 51 | + * |
| 52 | + * The mailmap must be freed with 'git_mailmap_free'. |
| 53 | + * |
| 54 | + * @param out pointer to store the mailmap |
| 55 | + * @param treeish root object that can be peeled to a tree |
| 56 | + * @return 0 on success; GIT_ENOTFOUND if .mailmap does not exist. |
| 57 | + */ |
| 58 | +GIT_EXTERN(int) git_mailmap_from_tree( |
| 59 | + git_mailmap **out, |
| 60 | + const git_object *treeish); |
28 | 61 |
|
29 | | -GIT_EXTERN(int) git_mailmap_create(git_mailmap**, git_repository*); |
30 | | -GIT_EXTERN(void) git_mailmap_free(git_mailmap*); |
31 | | -GIT_EXTERN(struct git_mailmap_entry) git_mailmap_lookup( |
32 | | - git_mailmap* map, |
33 | | - const char* name, |
34 | | - const char* email); |
| 62 | +/** |
| 63 | + * Create a mailmap object by parsing the ".mailmap" file in the repository's |
| 64 | + * HEAD's tree root. |
| 65 | + * |
| 66 | + * The mailmap must be freed with 'git_mailmap_free'. |
| 67 | + * |
| 68 | + * @param out pointer to store the mailmap |
| 69 | + * @param repo repository to find the .mailmap in |
| 70 | + * @return 0 on success; GIT_ENOTFOUND if .mailmap does not exist. |
| 71 | + */ |
| 72 | +GIT_EXTERN(int) git_mailmap_from_repo( |
| 73 | + git_mailmap **out, |
| 74 | + git_repository *repo); |
| 75 | + |
| 76 | +/** |
| 77 | + * Free a mailmap created by 'git_mailmap_parse', 'git_mailmap_from_tree' or |
| 78 | + * 'git_mailmap_from_repo'. |
| 79 | + */ |
| 80 | +GIT_EXTERN(void) git_mailmap_free(git_mailmap *mailmap); |
| 81 | + |
| 82 | +/** |
| 83 | + * Resolve a name and email to the corresponding real name and email. |
| 84 | + * |
| 85 | + * @param name_out either 'name', or the real name to use. |
| 86 | + * You should NOT free this value. |
| 87 | + * @param email_out either 'email' or the real email to use, |
| 88 | + * You should NOT free this value. |
| 89 | + * @param mailmap the mailmap to perform the lookup in. |
| 90 | + * @param name the name to resolve. |
| 91 | + * @param email the email to resolve. |
| 92 | + */ |
| 93 | +GIT_EXTERN(void) git_mailmap_resolve( |
| 94 | + const char **name_out, |
| 95 | + const char **email_out, |
| 96 | + git_mailmap *mailmap, |
| 97 | + const char *name, |
| 98 | + const char *email); |
| 99 | + |
| 100 | +/** |
| 101 | + * Get the number of mailmap entries. |
| 102 | + */ |
| 103 | +GIT_EXTERN(size_t) git_mailmap_entry_count(git_mailmap *mailmap); |
| 104 | + |
| 105 | +/** |
| 106 | + * Lookup a mailmap entry by index. |
| 107 | + * |
| 108 | + * Do not free the mailmap entry, it is owned by the mailmap. |
| 109 | + */ |
| 110 | +GIT_EXTERN(git_mailmap_entry *) git_mailmap_entry_byindex( |
| 111 | + git_mailmap *mailmap, |
| 112 | + size_t idx); |
| 113 | + |
| 114 | +/** |
| 115 | + * Lookup a mailmap entry by name/email pair. |
| 116 | + * |
| 117 | + * Do not free the mailmap entry, it is owned by the mailmap. |
| 118 | + */ |
| 119 | +GIT_EXTERN(git_mailmap_entry *) git_mailmap_entry_lookup( |
| 120 | + git_mailmap *mailmap, |
| 121 | + const char *name, |
| 122 | + const char *email); |
35 | 123 |
|
36 | 124 | /** @} */ |
37 | 125 | GIT_END_DECL |
38 | | - |
39 | 126 | #endif |
0 commit comments