From 7f8fe1d45e086adc9e7f3f0c33b624eeb3774033 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Tue, 1 Dec 2015 10:03:56 +0100 Subject: commit: introduce `git_commit_body` It is already possible to get a commit's summary with the `git_commit_summary` function. It is not possible to get the remaining part of the commit message, that is the commit message's body. Fix this by introducing a new function `git_commit_body`. --- include/git2/commit.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'include/git2') diff --git a/include/git2/commit.h b/include/git2/commit.h index 04711c1fa..34d29ed81 100644 --- a/include/git2/commit.h +++ b/include/git2/commit.h @@ -127,6 +127,19 @@ GIT_EXTERN(const char *) git_commit_message_raw(const git_commit *commit); */ GIT_EXTERN(const char *) git_commit_summary(git_commit *commit); +/** + * Get the long "body" of the git commit message. + * + * The returned message is the body of the commit, comprising + * everything but the first paragraph of the message. Leading and + * trailing whitespaces are trimmed. + * + * @param commit a previously loaded commit. + * @return the body of a commit or NULL when no the message only + * consists of a summary + */ +GIT_EXTERN(const char *) git_commit_body(git_commit *commit); + /** * Get the commit time (i.e. committer time) of a commit. * -- cgit v1.2.1 From 254e0a33ee66c65948e15efbe93a810c4077e324 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Tue, 24 Nov 2015 13:43:43 +0100 Subject: diff: include commit message when formatting patch When formatting a patch as email we do not include the commit's message in the formatted patch output. Implement this and add a test that verifies behavior. --- include/git2/diff.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'include/git2') diff --git a/include/git2/diff.h b/include/git2/diff.h index cbffdb49a..3eb265652 100644 --- a/include/git2/diff.h +++ b/include/git2/diff.h @@ -1286,12 +1286,15 @@ typedef struct { /** Summary of the change */ const char *summary; + /** Commit message's body */ + const char *body; + /** Author of the change */ const git_signature *author; } git_diff_format_email_options; #define GIT_DIFF_FORMAT_EMAIL_OPTIONS_VERSION 1 -#define GIT_DIFF_FORMAT_EMAIL_OPTIONS_INIT {GIT_DIFF_FORMAT_EMAIL_OPTIONS_VERSION, 0, 1, 1, NULL, NULL, NULL} +#define GIT_DIFF_FORMAT_EMAIL_OPTIONS_INIT {GIT_DIFF_FORMAT_EMAIL_OPTIONS_VERSION, 0, 1, 1, NULL, NULL, NULL, NULL} /** * Create an e-mail ready patch from a diff. -- cgit v1.2.1