Commit f407d3fa by Edward Thomson

diff_commit_as_email: use `email_create`

Move the `git_diff_commit_as_email` function to use `email_create`.
parent 3f13d2e8
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "diff.h" #include "diff.h"
#include "git2/version.h" #include "git2/version.h"
#include "git2/email.h"
#include "diff_generate.h" #include "diff_generate.h"
#include "patch.h" #include "patch.h"
#include "commit.h" #include "commit.h"
...@@ -323,26 +324,28 @@ int git_diff_commit_as_email( ...@@ -323,26 +324,28 @@ int git_diff_commit_as_email(
const git_diff_options *diff_opts) const git_diff_options *diff_opts)
{ {
git_diff *diff = NULL; git_diff *diff = NULL;
git_diff_format_email_options opts = git_email_create_options opts = GIT_EMAIL_CREATE_OPTIONS_INIT;
GIT_DIFF_FORMAT_EMAIL_OPTIONS_INIT; const git_oid *commit_id;
const char *summary, *body;
const git_signature *author;
int error; int error;
GIT_ASSERT_ARG(out); GIT_ASSERT_ARG(out);
GIT_ASSERT_ARG(repo); GIT_ASSERT_ARG(repo);
GIT_ASSERT_ARG(commit); GIT_ASSERT_ARG(commit);
opts.flags = flags; commit_id = git_commit_id(commit);
opts.patch_no = patch_no; summary = git_commit_summary(commit);
opts.total_patches = total_patches; body = git_commit_body(commit);
opts.id = git_commit_id(commit); author = git_commit_author(commit);
opts.summary = git_commit_summary(commit);
opts.body = git_commit_body(commit); if ((flags & GIT_DIFF_FORMAT_EMAIL_EXCLUDE_SUBJECT_PATCH_MARKER) != 0)
opts.author = git_commit_author(commit); opts.subject_prefix = "";
if ((error = git_diff__commit(&diff, repo, commit, diff_opts)) < 0) if ((error = git_diff__commit(&diff, repo, commit, diff_opts)) < 0)
return error; 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); git_diff_free(diff);
return error; return error;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment