Skip to content

Commit 971ed75

Browse files
committed
email: introduce 'append_from_diff'
Introduce `git_email__append_from_diff` so that we don't always overwrite the input buffer.
1 parent f407d3f commit 971ed75

File tree

2 files changed

+51
-1
lines changed

2 files changed

+51
-1
lines changed

src/email.c

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* a Linking Exception. For full terms see the included COPYING file.
66
*/
77

8+
#include "email.h"
9+
810
#include "buffer.h"
911
#include "common.h"
1012
#include "diff_generate.h"
@@ -187,7 +189,7 @@ static int append_patches(git_buf *out, git_diff *diff)
187189
return error;
188190
}
189191

190-
int git_email_create_from_diff(
192+
int git_email__append_from_diff(
191193
git_buf *out,
192194
git_diff *diff,
193195
size_t patch_idx,
@@ -227,6 +229,29 @@ int git_email_create_from_diff(
227229
return error;
228230
}
229231

232+
int git_email_create_from_diff(
233+
git_buf *out,
234+
git_diff *diff,
235+
size_t patch_idx,
236+
size_t patch_count,
237+
const git_oid *commit_id,
238+
const char *summary,
239+
const char *body,
240+
const git_signature *author,
241+
const git_email_create_options *given_opts)
242+
{
243+
int error;
244+
245+
git_buf_sanitize(out);
246+
git_buf_clear(out);
247+
248+
error = git_email__append_from_diff(out, diff, patch_idx,
249+
patch_count, commit_id, summary, body, author,
250+
given_opts);
251+
252+
return error;
253+
}
254+
230255
int git_email_create_from_commit(
231256
git_buf *out,
232257
git_commit *commit,

src/email.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright (C) the libgit2 contributors. All rights reserved.
3+
*
4+
* This file is part of libgit2, distributed under the GNU GPL v2 with
5+
* a Linking Exception. For full terms see the included COPYING file.
6+
*/
7+
#ifndef INCLUDE_email_h__
8+
#define INCLUDE_email_h__
9+
10+
#include "common.h"
11+
12+
#include "git2/email.h"
13+
14+
extern int git_email__append_from_diff(
15+
git_buf *out,
16+
git_diff *diff,
17+
size_t patch_idx,
18+
size_t patch_count,
19+
const git_oid *commit_id,
20+
const char *summary,
21+
const char *body,
22+
const git_signature *author,
23+
const git_email_create_options *given_opts);
24+
25+
#endif

0 commit comments

Comments
 (0)