diff options
| author | Jacques Germishuys <jacquesg@striata.com> | 2014-04-11 19:15:15 +0200 | 
|---|---|---|
| committer | Jacques Germishuys <jacquesg@striata.com> | 2014-04-15 17:22:17 +0200 | 
| commit | d8cc1fb653387d9acc28b075147084cf452c43dc (patch) | |
| tree | 16a50ea72ce6b00d10fa6b9e970fb04918b46caa /include/git2 | |
| parent | 360314c9dbb383b3737876a9c229e22050ec9c49 (diff) | |
| download | libgit2-d8cc1fb653387d9acc28b075147084cf452c43dc.tar.gz | |
Introduce git_diff_format_email and git_diff_commit_as_email
Diffstat (limited to 'include/git2')
| -rw-r--r-- | include/git2/diff.h | 88 | 
1 files changed, 88 insertions, 0 deletions
diff --git a/include/git2/diff.h b/include/git2/diff.h index 571f0c887..a0cfbc918 100644 --- a/include/git2/diff.h +++ b/include/git2/diff.h @@ -1158,6 +1158,94 @@ GIT_EXTERN(int) git_diff_stats_to_buf(   */  GIT_EXTERN(void) git_diff_stats_free(git_diff_stats *stats); +/** + * Formatting options for diff e-mail generation + */ +typedef enum { +	/** Normal patch, the default */ +	GIT_DIFF_FORMAT_EMAIL_NONE = 0, + +	/** Don't insert "[PATCH]" in the subject header*/ +	GIT_DIFF_FORMAT_EMAIL_EXCLUDE_SUBJECT_PATCH_MARKER = (1 << 0), + +} git_diff_format_email_flags_t; + +/** + * Options for controlling the formatting of the generated e-mail. + */ +typedef struct { +	unsigned int version; + +	git_diff_format_email_flags_t flags; + +	/** This patch number */ +	size_t patch_no; + +	/** Total number of patches in this series */ +	size_t total_patches; + +	/** id to use for the commit */ +	const git_oid *id; + +	/** Summary of the change */ +	const char *summary; + +	/** Author of the change */ +	const git_signature *author; +} git_diff_format_email_options; + +#define GIT_DIFF_FORMAT_EMAIL_OPTIONS_VERSION 1 +#define GIT_DIFF_FORMAT_EMAIL_OPTIONS_INIT {GIT_DIFF_FORMAT_EMAIL_OPTIONS_VERSION, 0, 1, 1, NULL, NULL, NULL} + +/** + * Create an e-mail ready patch from a diff. + * + * @param out buffer to store the e-mail patch in + * @param diff containing the commit + * @param opts structure with options to influence content and formatting. + * @return 0 or an error code + */ +GIT_EXTERN(int) git_diff_format_email( +	git_buf *out, +	git_diff *diff, +	const git_diff_format_email_options *opts); + +/** + * Create an e-mail ready patch for a commit. + * + * Does not support creating patches for merge commits (yet). + * + * @param out buffer to store the e-mail patch in + * @param repo containing the commit + * @param commit pointer to up commit + * @param patch_no patch number of the commit + * @param total_patches total number of patches in the patch set + * @param flags determines the formatting of the e-mail + * @param diff_opts structure with options to influence diff or NULL for defaults. + * @return 0 or an error code + */ +GIT_EXTERN(int) git_diff_commit_as_email( +	git_buf *out, +	git_repository *repo, +	git_commit *commit, +	size_t patch_no, +	size_t total_patches, +	git_diff_format_email_flags_t flags, +	const git_diff_options *diff_opts); + +/** +* Initializes a `git_diff_format_email_options` with default values. Equivalent to +* creating an instance with GIT_DIFF_FORMAT_EMAIL_OPTIONS_INIT. +* +* @param opts the `git_diff_format_email_options` instance to initialize. +* @param version the version of the struct; you should pass +* `GIT_DIFF_FORMAT_EMAIL_OPTIONS_VERSION` here. +* @return Zero on success; -1 on failure. +*/ +GIT_EXTERN(int) git_diff_format_email_init_options( +	git_diff_format_email_options *opts, +	int version); +  GIT_END_DECL  /** @} */  | 
