diff options
author | Brian Lopez <seniorlopez@gmail.com> | 2018-01-16 13:40:26 -0800 |
---|---|---|
committer | Brian Lopez <seniorlopez@gmail.com> | 2018-01-16 19:33:04 -0800 |
commit | d43974fb5cbfda6ec28fc92b83d03db0af73748b (patch) | |
tree | e4463bcef64fa25df880a89003268a956a21af7e /include/git2 | |
parent | 5734768b9edaecedaa7b13fed2ce59cb588df7e8 (diff) | |
download | libgit2-d43974fb5cbfda6ec28fc92b83d03db0af73748b.tar.gz |
Change trailer API to return a simple array
Diffstat (limited to 'include/git2')
-rw-r--r-- | include/git2/message.h | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/include/git2/message.h b/include/git2/message.h index a74dcc2d9..e3c9fe787 100644 --- a/include/git2/message.h +++ b/include/git2/message.h @@ -38,7 +38,18 @@ GIT_BEGIN_DECL */ GIT_EXTERN(int) git_message_prettify(git_buf *out, const char *message, int strip_comments, char comment_char); -typedef int(*git_message_trailer_cb)(const char *key, const char *value, void *payload); +typedef struct { + const char *key; + const char *value; +} git_message_trailer; + +typedef struct { + git_message_trailer *trailers; + size_t count; + + /* private */ + char *_trailer_block; +} git_message_trailer_array; /** * Parse trailers out of a message, calling a callback once for each trailer. @@ -48,15 +59,14 @@ typedef int(*git_message_trailer_cb)(const char *key, const char *value, void *p * Trailers are key/value pairs in the last paragraph of a message, not * including any patches or conflicts that may be present. * + * @param arr A pre-allocated git_message_trailer_array struct to be filled in + * with any trailers found during parsing. * @param message The message to be parsed - * @param cb The callback to call for each trailer found in the message. The - * key and value arguments are pointers to NUL-terminated C strings. These - * pointers are only guaranteed to be valid until the callback returns. - * User code must make a copy of this data should it need to be retained - * @param payload Pointer to callback data (optional) * @return 0 on success, or non-zero callback return value. */ -GIT_EXTERN(int) git_message_trailers(const char *message, git_message_trailer_cb cb, void *payload); +GIT_EXTERN(int) git_message_trailers(git_message_trailer_array *arr, const char *message); + +GIT_EXTERN(void) git_message_trailer_array_free(git_message_trailer_array *arr); /** @} */ GIT_END_DECL |