summaryrefslogtreecommitdiff
path: root/src/diff.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2015-11-24 13:43:43 +0100
committerPatrick Steinhardt <ps@pks.im>2015-12-01 10:12:53 +0100
commit254e0a33ee66c65948e15efbe93a810c4077e324 (patch)
tree5d1729f99eb588a1caacd6cd764958643889bfd8 /src/diff.c
parent7f8fe1d45e086adc9e7f3f0c33b624eeb3774033 (diff)
downloadlibgit2-254e0a33ee66c65948e15efbe93a810c4077e324.tar.gz
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.
Diffstat (limited to 'src/diff.c')
-rw-r--r--src/diff.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/diff.c b/src/diff.c
index 9402b6e61..67fab0763 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -1659,6 +1659,7 @@ int git_diff_format_email__append_header_tobuf(
const git_oid *id,
const git_signature *author,
const char *summary,
+ const char *body,
size_t patch_no,
size_t total_patches,
bool exclude_patchno_marker)
@@ -1698,6 +1699,13 @@ int git_diff_format_email__append_header_tobuf(
error = git_buf_printf(out, "%s\n\n", summary);
+ if (body) {
+ git_buf_puts(out, body);
+
+ if (out->ptr[out->size - 1] != '\n')
+ git_buf_putc(out, '\n');
+ }
+
return error;
}
@@ -1775,7 +1783,7 @@ int git_diff_format_email(
error = git_diff_format_email__append_header_tobuf(out,
opts->id, opts->author, summary == NULL ? opts->summary : summary,
- opts->patch_no, opts->total_patches, ignore_marker);
+ opts->body, opts->patch_no, opts->total_patches, ignore_marker);
if (error < 0)
goto on_error;
@@ -1818,6 +1826,7 @@ int git_diff_commit_as_email(
opts.total_patches = total_patches;
opts.id = git_commit_id(commit);
opts.summary = git_commit_summary(commit);
+ opts.body = git_commit_body(commit);
opts.author = git_commit_author(commit);
if ((error = git_diff__commit(&diff, repo, commit, diff_opts)) < 0)