apply: add an options struct initializer
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
diff --git a/include/git2/apply.h b/include/git2/apply.h
index 91f93d7..384e117 100644
--- a/include/git2/apply.h
+++ b/include/git2/apply.h
@@ -57,7 +57,7 @@ typedef int GIT_CALLBACK(git_apply_hunk_cb)(
* Apply options structure
*
* Initialize with `GIT_APPLY_OPTIONS_INIT`. Alternatively, you can
- * use `git_apply_init_options`.
+ * use `git_apply_options_init`.
*
* @see git_apply_to_tree, git_apply
*/
@@ -72,6 +72,8 @@ typedef struct {
#define GIT_APPLY_OPTIONS_VERSION 1
#define GIT_APPLY_OPTIONS_INIT {GIT_APPLY_OPTIONS_VERSION}
+GIT_EXTERN(int) git_apply_options_init(git_apply_options *opts, unsigned int version);
+
/**
* Apply a `git_diff` to a `git_tree`, and return the resulting image
* as an index.
diff --git a/src/apply.c b/src/apply.c
index 156221f..fdafa66 100644
--- a/src/apply.c
+++ b/src/apply.c
@@ -745,6 +745,13 @@ done:
return error;
}
+int git_apply_options_init(git_apply_options *opts, unsigned int version)
+{
+ GIT_INIT_STRUCTURE_FROM_TEMPLATE(
+ opts, version, git_apply_options, GIT_APPLY_OPTIONS_INIT);
+ return 0;
+}
+
/*
* Handle the three application options ("locations"):
*
diff --git a/tests/core/structinit.c b/tests/core/structinit.c
index 82286a2..f9da823 100644
--- a/tests/core/structinit.c
+++ b/tests/core/structinit.c
@@ -72,6 +72,11 @@ void test_core_structinit__compare(void)
clar__skip();
#endif
+ /* apply */
+ CHECK_MACRO_FUNC_INIT_EQUAL( \
+ git_apply_options, GIT_APPLY_OPTIONS_VERSION, \
+ GIT_APPLY_OPTIONS_INIT, git_apply_options_init);
+
/* blame */
CHECK_MACRO_FUNC_INIT_EQUAL( \
git_blame_options, GIT_BLAME_OPTIONS_VERSION, \