summaryrefslogtreecommitdiff
path: root/include/git2/message.h
diff options
context:
space:
mode:
authorCharlie Somerville <charlie@charlie.bz>2017-12-14 18:37:10 +1100
committerCharlie Somerville <charlie@charlie.bz>2017-12-19 15:01:48 +1100
commit1c43edca1f4d14296ed94822df68d17aee2af549 (patch)
treef7c8cd055a4ecad35a8130efd4ba26df33ea0cf9 /include/git2/message.h
parent1bf173c33a217a2e4766d8c144b7935010dfa7d6 (diff)
downloadlibgit2-1c43edca1f4d14296ed94822df68d17aee2af549.tar.gz
message: add routine for parsing trailers from messages
This is implemented in trailer.c and borrows a large amount of logic from Git core to ensure compatibility.
Diffstat (limited to 'include/git2/message.h')
-rw-r--r--include/git2/message.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/include/git2/message.h b/include/git2/message.h
index d78b1dce5..85fbf5676 100644
--- a/include/git2/message.h
+++ b/include/git2/message.h
@@ -38,6 +38,29 @@ 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);
+
+/**
+ * Parse trailers out of a message, calling a callback once for each trailer.
+ *
+ * Return non-zero from the callback to stop processing.
+ *
+ * Trailers are key/value pairs in the last paragraph of a message, not
+ * including any patches or conflicts that may be present.
+ *
+ * @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_END_DECL