Skip to content

Commit c0dd712

Browse files
committed
apply: add an options struct initializer
1 parent 0b5ba0d commit c0dd712

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

include/git2/apply.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ typedef int GIT_CALLBACK(git_apply_hunk_cb)(
5757
* Apply options structure
5858
*
5959
* Initialize with `GIT_APPLY_OPTIONS_INIT`. Alternatively, you can
60-
* use `git_apply_init_options`.
60+
* use `git_apply_options_init`.
6161
*
6262
* @see git_apply_to_tree, git_apply
6363
*/
@@ -72,6 +72,8 @@ typedef struct {
7272
#define GIT_APPLY_OPTIONS_VERSION 1
7373
#define GIT_APPLY_OPTIONS_INIT {GIT_APPLY_OPTIONS_VERSION}
7474

75+
GIT_EXTERN(int) git_apply_options_init(git_apply_options *opts, unsigned int version);
76+
7577
/**
7678
* Apply a `git_diff` to a `git_tree`, and return the resulting image
7779
* as an index.

src/apply.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,13 @@ static int git_apply__to_index(
745745
return error;
746746
}
747747

748+
int git_apply_options_init(git_apply_options *opts, unsigned int version)
749+
{
750+
GIT_INIT_STRUCTURE_FROM_TEMPLATE(
751+
opts, version, git_apply_options, GIT_APPLY_OPTIONS_INIT);
752+
return 0;
753+
}
754+
748755
/*
749756
* Handle the three application options ("locations"):
750757
*

tests/core/structinit.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ void test_core_structinit__compare(void)
7272
clar__skip();
7373
#endif
7474

75+
/* apply */
76+
CHECK_MACRO_FUNC_INIT_EQUAL( \
77+
git_apply_options, GIT_APPLY_OPTIONS_VERSION, \
78+
GIT_APPLY_OPTIONS_INIT, git_apply_options_init);
79+
7580
/* blame */
7681
CHECK_MACRO_FUNC_INIT_EQUAL( \
7782
git_blame_options, GIT_BLAME_OPTIONS_VERSION, \

0 commit comments

Comments
 (0)