summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2021-09-13 13:26:55 -0400
committerEdward Thomson <ethomson@edwardthomson.com>2021-09-18 08:32:41 -0400
commit971ed7537cae0b7f27dab7fa310d71a4cce3db27 (patch)
tree945ef22c07ad54aa6077f47f31d661deb1632119
parentf407d3fae5983411a5d785fa2f0c29a84cbb9d52 (diff)
downloadlibgit2-971ed7537cae0b7f27dab7fa310d71a4cce3db27.tar.gz
email: introduce 'append_from_diff'
Introduce `git_email__append_from_diff` so that we don't always overwrite the input buffer.
-rw-r--r--src/email.c27
-rw-r--r--src/email.h25
2 files changed, 51 insertions, 1 deletions
diff --git a/src/email.c b/src/email.c
index b238f5b47..0bec5155c 100644
--- a/src/email.c
+++ b/src/email.c
@@ -5,6 +5,8 @@
* a Linking Exception. For full terms see the included COPYING file.
*/
+#include "email.h"
+
#include "buffer.h"
#include "common.h"
#include "diff_generate.h"
@@ -187,7 +189,7 @@ static int append_patches(git_buf *out, git_diff *diff)
return error;
}
-int git_email_create_from_diff(
+int git_email__append_from_diff(
git_buf *out,
git_diff *diff,
size_t patch_idx,
@@ -227,6 +229,29 @@ int git_email_create_from_diff(
return error;
}
+int git_email_create_from_diff(
+ git_buf *out,
+ git_diff *diff,
+ size_t patch_idx,
+ size_t patch_count,
+ const git_oid *commit_id,
+ const char *summary,
+ const char *body,
+ const git_signature *author,
+ const git_email_create_options *given_opts)
+{
+ int error;
+
+ git_buf_sanitize(out);
+ git_buf_clear(out);
+
+ error = git_email__append_from_diff(out, diff, patch_idx,
+ patch_count, commit_id, summary, body, author,
+ given_opts);
+
+ return error;
+}
+
int git_email_create_from_commit(
git_buf *out,
git_commit *commit,
diff --git a/src/email.h b/src/email.h
new file mode 100644
index 000000000..7aeb462ab
--- /dev/null
+++ b/src/email.h
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) the libgit2 contributors. All rights reserved.
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+#ifndef INCLUDE_email_h__
+#define INCLUDE_email_h__
+
+#include "common.h"
+
+#include "git2/email.h"
+
+extern int git_email__append_from_diff(
+ git_buf *out,
+ git_diff *diff,
+ size_t patch_idx,
+ size_t patch_count,
+ const git_oid *commit_id,
+ const char *summary,
+ const char *body,
+ const git_signature *author,
+ const git_email_create_options *given_opts);
+
+#endif