Skip to content

Commit 27e34f9

Browse files
authored
Merge pull request libgit2#5759 from JoshuaS3/master
Add documentation for git_blob_filter_options.version
2 parents f0d7922 + ddafbaf commit 27e34f9

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

include/git2/blob.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ typedef enum {
118118

119119
/**
120120
* The options used when applying filter options to a file.
121+
*
122+
* Initialize with `GIT_BLOB_FILTER_OPTIONS_INIT`. Alternatively, you can
123+
* use `git_blob_filter_options_init`.
124+
*
121125
*/
122126
typedef struct {
123127
int version;
@@ -129,6 +133,18 @@ typedef struct {
129133
#define GIT_BLOB_FILTER_OPTIONS_VERSION 1
130134
#define GIT_BLOB_FILTER_OPTIONS_INIT {GIT_BLOB_FILTER_OPTIONS_VERSION, GIT_BLOB_FILTER_CHECK_FOR_BINARY}
131135

136+
/**
137+
* Initialize git_blob_filter_options structure
138+
*
139+
* Initializes a `git_blob_filter_options` with default values. Equivalent
140+
* to creating an instance with `GIT_BLOB_FILTER_OPTIONS_INIT`.
141+
*
142+
* @param opts The `git_blob_filter_options` struct to initialize.
143+
* @param version The struct version; pass `GIT_BLOB_FILTER_OPTIONS_VERSION`.
144+
* @return Zero on success; -1 on failure.
145+
*/
146+
GIT_EXTERN(int) git_blob_filter_options_init(git_blob_filter_options *opts, unsigned int version);
147+
132148
/**
133149
* Get a buffer with the filtered content of a blob.
134150
*

src/blob.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,15 @@ int git_blob_is_binary(const git_blob *blob)
408408
return git_buf_text_is_binary(&content);
409409
}
410410

411+
int git_blob_filter_options_init(
412+
git_blob_filter_options *opts,
413+
unsigned int version)
414+
{
415+
GIT_INIT_STRUCTURE_FROM_TEMPLATE(opts, version,
416+
git_blob_filter_options, GIT_BLOB_FILTER_OPTIONS_INIT);
417+
return 0;
418+
}
419+
411420
int git_blob_filter(
412421
git_buf *out,
413422
git_blob *blob,

tests/core/structinit.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ void test_core_structinit__compare(void)
8282
git_blame_options, GIT_BLAME_OPTIONS_VERSION, \
8383
GIT_BLAME_OPTIONS_INIT, git_blame_options_init);
8484

85+
/* blob_filter_options */
86+
CHECK_MACRO_FUNC_INIT_EQUAL( \
87+
git_blob_filter_options, GIT_BLOB_FILTER_OPTIONS_VERSION, \
88+
GIT_BLOB_FILTER_OPTIONS_INIT, git_blob_filter_options_init);
89+
8590
/* checkout */
8691
CHECK_MACRO_FUNC_INIT_EQUAL( \
8792
git_checkout_options, GIT_CHECKOUT_OPTIONS_VERSION, \

0 commit comments

Comments
 (0)