diff options
author | Russell Belfer <rb@github.com> | 2013-09-11 14:23:39 -0700 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2013-09-17 09:31:45 -0700 |
commit | 40cb40fab93281c808255d980bbe81a18a4d9e9a (patch) | |
tree | 349cfd168a3a704288a3222f69374064e7d86c91 /include/git2 | |
parent | 0646634e2fea3e0adf724e0b7b15118574b589fc (diff) | |
download | libgit2-40cb40fab93281c808255d980bbe81a18a4d9e9a.tar.gz |
Add functions to manipulate filter lists
Extend the git2/sys/filter API with functions to look up a filter
and add it manually to a filter list. This requires some trickery
because the regular attribute lookups and checks are bypassed when
this happens, but in the right hands, it will allow a user to have
granular control over applying filters.
Diffstat (limited to 'include/git2')
-rw-r--r-- | include/git2/filter.h | 17 | ||||
-rw-r--r-- | include/git2/sys/filter.h | 37 |
2 files changed, 37 insertions, 17 deletions
diff --git a/include/git2/filter.h b/include/git2/filter.h index cb23ae4f4..8ef88d81b 100644 --- a/include/git2/filter.h +++ b/include/git2/filter.h @@ -63,23 +63,6 @@ typedef struct git_filter git_filter; typedef struct git_filter_list git_filter_list; /** - * Look up a filter by name - */ -GIT_EXTERN(git_filter *) git_filter_lookup(const char *name); - -#define GIT_FILTER_CRLF "crlf" - -/** - * Apply a single filter to a buffer of data - */ -GIT_EXTERN(int) git_filter_apply_to_buffer( - git_buffer *out, - git_filter *filter, - const git_buffer *input, - const char *as_path, - git_filter_mode_t mode); - -/** * Load the filter list for a given path. * * This will return 0 (success) but set the output git_filter_list to NULL diff --git a/include/git2/sys/filter.h b/include/git2/sys/filter.h index dbb086b0e..ca5738a53 100644 --- a/include/git2/sys/filter.h +++ b/include/git2/sys/filter.h @@ -19,6 +19,43 @@ GIT_BEGIN_DECL /** + * Look up a filter by name + * + * @param name The name of the filter + * @return Pointer to the filter object or NULL if not found + */ +GIT_EXTERN(git_filter *) git_filter_lookup(const char *name); + +#define GIT_FILTER_CRLF "crlf" + +/** + * Create a new empty filter list + * + * Normally you won't use this because `git_filter_list_load` will create + * the filter list for you, but you can use this in combination with the + * `git_filter_lookup` and `git_filter_list_push` functions to assemble + * your own chains of filters. + */ +GIT_EXTERN(int) git_filter_list_new( + git_filter_list **out, git_repository *repo, git_filter_mode_t mode); + +/** + * Add a filter to a filter list with the given payload. + * + * Normally you won't have to do this because the filter list is created + * by calling the "check" function on registered filters when the filter + * attributes are set, but this does allow more direct manipulation of + * filter lists when desired. + * + * Note that normally the "check" function can set up a payload for the + * filter. Using this function, you can either pass in a payload if you + * know the expected payload format, or you can pass NULL. Some filters + * may fail with a NULL payload. Good luck! + */ +GIT_EXTERN(int) git_filter_list_push( + git_filter_list *fl, git_filter *filter, void *payload); + +/** * A filter source represents a file/blob to be processed */ typedef struct git_filter_source git_filter_source; |