diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2017-06-14 10:49:28 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-14 10:49:28 +0200 |
commit | 8296da5f60f5b079bed9c944e1d56ad786ae0ecb (patch) | |
tree | 0ef9b1b043a08988dff951cfdcbed752edf9a08d | |
parent | 4e257dab4a70202037a9b08e17c50689a0e09ad7 (diff) | |
parent | a78441bc467f964261f24b2a1d011cc84fc96708 (diff) | |
download | libgit2-8296da5f60f5b079bed9c944e1d56ad786ae0ecb.tar.gz |
Merge pull request #4267 from mohseenrm/master
adding GIT_FILTER_VERSION to GIT_FILTER_INIT as part of convention
-rw-r--r-- | include/git2/sys/filter.h | 11 | ||||
-rw-r--r-- | src/filter.c | 8 | ||||
-rw-r--r-- | tests/core/structinit.c | 6 |
3 files changed, 24 insertions, 1 deletions
diff --git a/include/git2/sys/filter.h b/include/git2/sys/filter.h index d0e5d4d6f..6d575d4fd 100644 --- a/include/git2/sys/filter.h +++ b/include/git2/sys/filter.h @@ -271,6 +271,17 @@ struct git_filter { }; #define GIT_FILTER_VERSION 1 +#define GIT_FILTER_INIT {GIT_FILTER_VERSION} + +/** + * Initializes a `git_filter` with default values. Equivalent to + * creating an instance with GIT_FILTER_INIT. + * + * @param filter the `git_filter` struct to initialize. + * @param version Version the struct; pass `GIT_FILTER_VERSION` + * @return Zero on success; -1 on failure. + */ +GIT_EXTERN(int) git_filter_init(git_filter *filter, unsigned int version); /** * Register a filter under a given name with a given priority. diff --git a/src/filter.c b/src/filter.c index e74cc1053..361e08529 100644 --- a/src/filter.c +++ b/src/filter.c @@ -895,7 +895,7 @@ static int stream_list_init( git_array_size(filters->filters) - 1 - i : i; git_filter_entry *fe = git_array_get(filters->filters, filter_idx); git_writestream *filter_stream; - + assert(fe->filter->stream || fe->filter->apply); /* If necessary, create a stream that proxies the traditional @@ -1022,3 +1022,9 @@ int git_filter_list_stream_blob( return git_filter_list_stream_data(filters, &in, target); } + +int git_filter_init(git_filter *filter, unsigned int version) +{ + GIT_INIT_STRUCTURE_FROM_TEMPLATE(filter, version, git_filter, GIT_FILTER_INIT); + return 0; +} diff --git a/tests/core/structinit.c b/tests/core/structinit.c index 2d214405f..78503fcc6 100644 --- a/tests/core/structinit.c +++ b/tests/core/structinit.c @@ -1,5 +1,6 @@ #include "clar_libgit2.h" #include <git2/sys/config.h> +#include <git2/sys/filter.h> #include <git2/sys/odb_backend.h> #include <git2/sys/refdb_backend.h> #include <git2/sys/transport.h> @@ -96,6 +97,11 @@ void test_core_structinit__compare(void) git_diff_find_options, GIT_DIFF_FIND_OPTIONS_VERSION, \ GIT_DIFF_FIND_OPTIONS_INIT, git_diff_find_init_options); + /* filter */ + CHECK_MACRO_FUNC_INIT_EQUAL( \ + git_filter, GIT_FILTER_VERSION, \ + GIT_FILTER_INIT, git_filter_init); + /* merge_file_input */ CHECK_MACRO_FUNC_INIT_EQUAL( \ git_merge_file_input, GIT_MERGE_FILE_INPUT_VERSION, \ |