summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2021-09-13 10:51:42 -0400
committerEdward Thomson <ethomson@edwardthomson.com>2021-09-18 08:32:41 -0400
commitf407d3fae5983411a5d785fa2f0c29a84cbb9d52 (patch)
tree3e0aebb44283fd1ae78c47546b6f60049cb11351
parent3f13d2e8a3244018ae4e94d115b419eb84924ed6 (diff)
downloadlibgit2-f407d3fae5983411a5d785fa2f0c29a84cbb9d52.tar.gz
diff_commit_as_email: use `email_create`
Move the `git_diff_commit_as_email` function to use `email_create`.
-rw-r--r--src/diff.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/diff.c b/src/diff.c
index 4085c5f78..ed12cbe3e 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -8,6 +8,7 @@
#include "diff.h"
#include "git2/version.h"
+#include "git2/email.h"
#include "diff_generate.h"
#include "patch.h"
#include "commit.h"
@@ -323,26 +324,28 @@ int git_diff_commit_as_email(
const git_diff_options *diff_opts)
{
git_diff *diff = NULL;
- git_diff_format_email_options opts =
- GIT_DIFF_FORMAT_EMAIL_OPTIONS_INIT;
+ git_email_create_options opts = GIT_EMAIL_CREATE_OPTIONS_INIT;
+ const git_oid *commit_id;
+ const char *summary, *body;
+ const git_signature *author;
int error;
GIT_ASSERT_ARG(out);
GIT_ASSERT_ARG(repo);
GIT_ASSERT_ARG(commit);
- opts.flags = flags;
- opts.patch_no = patch_no;
- 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);
+ commit_id = git_commit_id(commit);
+ summary = git_commit_summary(commit);
+ body = git_commit_body(commit);
+ author = git_commit_author(commit);
+
+ if ((flags & GIT_DIFF_FORMAT_EMAIL_EXCLUDE_SUBJECT_PATCH_MARKER) != 0)
+ opts.subject_prefix = "";
if ((error = git_diff__commit(&diff, repo, commit, diff_opts)) < 0)
return error;
- error = git_diff_format_email(out, diff, &opts);
+ error = git_email_create_from_diff(out, diff, patch_no, total_patches, commit_id, summary, body, author, &opts);
git_diff_free(diff);
return error;