diff options
author | Brian Lopez <seniorlopez@gmail.com> | 2018-01-17 13:54:42 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-17 13:54:42 -0800 |
commit | 4893a9c01c8da084eb995178f80d0d453109056e (patch) | |
tree | bfe94f6be3e56a211205075ecdf863a3195c3423 /include/git2 | |
parent | ecd55cec771d9c6f7ffffe80422a1decd4645c17 (diff) | |
parent | d4a3a4b5383fefcb397524340af05118b4687f29 (diff) | |
download | libgit2-4893a9c01c8da084eb995178f80d0d453109056e.tar.gz |
Merge pull request #4451 from libgit2/charliesome/trailer-info
Implement message trailer parsing API
Diffstat (limited to 'include/git2')
-rw-r--r-- | include/git2/message.h | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/include/git2/message.h b/include/git2/message.h index d78b1dce5..329346285 100644 --- a/include/git2/message.h +++ b/include/git2/message.h @@ -38,6 +38,47 @@ GIT_BEGIN_DECL */ GIT_EXTERN(int) git_message_prettify(git_buf *out, const char *message, int strip_comments, char comment_char); +/** + * Represents a single git message trailer. + */ +typedef struct { + const char *key; + const char *value; +} git_message_trailer; + +/** + * Represents an array of git message trailers. + * + * Struct members under the private comment are private, subject to change + * and should not be used by callers. + */ +typedef struct { + git_message_trailer *trailers; + size_t count; + + /* private */ + char *_trailer_block; +} git_message_trailer_array; + +/** + * Parse trailers out of a message, filling the array pointed to by +arr+. + * + * 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 + * @return 0 on success, or non-zero on error. + */ +GIT_EXTERN(int) git_message_trailers(git_message_trailer_array *arr, const char *message); + +/** + * Clean's up any allocated memory in the git_message_trailer_array filled by + * a call to git_message_trailers. + */ +GIT_EXTERN(void) git_message_trailer_array_free(git_message_trailer_array *arr); + /** @} */ GIT_END_DECL |