summaryrefslogtreecommitdiff
path: root/include/git2
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2018-07-08 16:12:58 +0100
committerEdward Thomson <ethomson@edwardthomson.com>2018-11-05 15:53:58 +0000
commit37b25ac57f78dc72e6bf4e516e24dc5010098cee (patch)
tree4d87b64b67f8332cf7d16d661e3bcbea7af0e224 /include/git2
parent2d27ddc02e22a3cffbfafcb42e6eac04baf7256f (diff)
downloadlibgit2-37b25ac57f78dc72e6bf4e516e24dc5010098cee.tar.gz
apply: move location to an argument, not the opts
Move the location option to an argument, out of the options structure. This allows the options structure to be re-used for functions that don't need to know the location, since it's implicit in their functionality. For example, `git_apply_tree` should not take a location, but is expected to take all the other options.
Diffstat (limited to 'include/git2')
-rw-r--r--include/git2/apply.h32
1 files changed, 21 insertions, 11 deletions
diff --git a/include/git2/apply.h b/include/git2/apply.h
index 3bf6aad63..cdeb9ed4c 100644
--- a/include/git2/apply.h
+++ b/include/git2/apply.h
@@ -22,6 +22,21 @@
GIT_BEGIN_DECL
/**
+ * Apply options structure
+ *
+ * Initialize with `GIT_APPLY_OPTIONS_INIT`. Alternatively, you can
+ * use `git_apply_init_options`.
+ *
+ * @see git_apply_to_tree, git_apply
+ */
+typedef struct {
+ unsigned int version;
+} git_apply_options;
+
+#define GIT_APPLY_OPTIONS_VERSION 1
+#define GIT_APPLY_OPTIONS_INIT {GIT_APPLY_OPTIONS_VERSION}
+
+/**
* Apply a `git_diff` to a `git_tree`, and return the resulting image
* as an index.
*
@@ -29,12 +44,14 @@ GIT_BEGIN_DECL
* @param repo the repository to apply
* @param preimage the tree to apply the diff to
* @param diff the diff to apply
+ * @param options the options for the apply (or null for defaults)
*/
GIT_EXTERN(int) git_apply_to_tree(
git_index **out,
git_repository *repo,
git_tree *preimage,
- git_diff *diff);
+ git_diff *diff,
+ const git_apply_options *options);
typedef enum {
/**
@@ -56,27 +73,20 @@ typedef enum {
GIT_APPLY_LOCATION_BOTH = 2,
} git_apply_location_t;
-typedef struct {
- unsigned int version;
-
- git_apply_location_t location;
-} git_apply_options;
-
-#define GIT_APPLY_OPTIONS_VERSION 1
-#define GIT_APPLY_OPTIONS_INIT {GIT_APPLY_OPTIONS_VERSION}
-
/**
* Apply a `git_diff` to the given repository, making changes directly
* in the working directory, the index, or both.
*
* @param repo the repository to apply to
* @param diff the diff to apply
+ * @param location the location to apply (workdir, index or both)
* @param options the options for the apply (or null for defaults)
*/
GIT_EXTERN(int) git_apply(
git_repository *repo,
git_diff *diff,
- git_apply_options *options);
+ git_apply_location_t location,
+ const git_apply_options *options);
/** @} */
GIT_END_DECL