|
8 | 8 | #include "diff.h" |
9 | 9 |
|
10 | 10 | #include "git2/version.h" |
| 11 | +#include "git2/email.h" |
11 | 12 | #include "diff_generate.h" |
12 | 13 | #include "patch.h" |
13 | 14 | #include "commit.h" |
@@ -323,26 +324,28 @@ int git_diff_commit_as_email( |
323 | 324 | const git_diff_options *diff_opts) |
324 | 325 | { |
325 | 326 | git_diff *diff = NULL; |
326 | | - git_diff_format_email_options opts = |
327 | | - GIT_DIFF_FORMAT_EMAIL_OPTIONS_INIT; |
| 327 | + git_email_create_options opts = GIT_EMAIL_CREATE_OPTIONS_INIT; |
| 328 | + const git_oid *commit_id; |
| 329 | + const char *summary, *body; |
| 330 | + const git_signature *author; |
328 | 331 | int error; |
329 | 332 |
|
330 | 333 | GIT_ASSERT_ARG(out); |
331 | 334 | GIT_ASSERT_ARG(repo); |
332 | 335 | GIT_ASSERT_ARG(commit); |
333 | 336 |
|
334 | | - opts.flags = flags; |
335 | | - opts.patch_no = patch_no; |
336 | | - opts.total_patches = total_patches; |
337 | | - opts.id = git_commit_id(commit); |
338 | | - opts.summary = git_commit_summary(commit); |
339 | | - opts.body = git_commit_body(commit); |
340 | | - opts.author = git_commit_author(commit); |
| 337 | + commit_id = git_commit_id(commit); |
| 338 | + summary = git_commit_summary(commit); |
| 339 | + body = git_commit_body(commit); |
| 340 | + author = git_commit_author(commit); |
| 341 | + |
| 342 | + if ((flags & GIT_DIFF_FORMAT_EMAIL_EXCLUDE_SUBJECT_PATCH_MARKER) != 0) |
| 343 | + opts.subject_prefix = ""; |
341 | 344 |
|
342 | 345 | if ((error = git_diff__commit(&diff, repo, commit, diff_opts)) < 0) |
343 | 346 | return error; |
344 | 347 |
|
345 | | - error = git_diff_format_email(out, diff, &opts); |
| 348 | + error = git_email_create_from_diff(out, diff, patch_no, total_patches, commit_id, summary, body, author, &opts); |
346 | 349 |
|
347 | 350 | git_diff_free(diff); |
348 | 351 | return error; |
|
0 commit comments