summaryrefslogtreecommitdiff
path: root/include/git2
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2021-06-16 09:08:38 +0100
committerEdward Thomson <ethomson@edwardthomson.com>2021-07-22 16:22:28 -0400
commitd7e8b9348cab441184b82c57cb2c847c11ffa5d8 (patch)
treede3d699604b82bd71f387d65829ef9eae895d5ae /include/git2
parent1db5b2199b89bca0c2787945c407fd8b57c0c598 (diff)
downloadlibgit2-d7e8b9348cab441184b82c57cb2c847c11ffa5d8.tar.gz
filter: add git_filter_options
Allow filter users to provide an options structure instead of simply flags. This allows for future growth for filter options.
Diffstat (limited to 'include/git2')
-rw-r--r--include/git2/filter.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/include/git2/filter.h b/include/git2/filter.h
index a0185ee88..545815171 100644
--- a/include/git2/filter.h
+++ b/include/git2/filter.h
@@ -52,6 +52,19 @@ typedef enum {
} git_filter_flag_t;
/**
+ * Filtering options
+ */
+typedef struct {
+ unsigned int version;
+
+ /** See `git_filter_flag_t` above */
+ uint32_t flags;
+} git_filter_options;
+
+ #define GIT_FILTER_OPTIONS_VERSION 1
+ #define GIT_FILTER_OPTIONS_INIT {GIT_FILTER_OPTIONS_VERSION}
+
+/**
* A filter that can transform file data
*
* This represents a filter that can be used to transform or even replace
@@ -104,6 +117,29 @@ GIT_EXTERN(int) git_filter_list_load(
uint32_t flags);
/**
+ * Load the filter list for a given path.
+ *
+ * This will return 0 (success) but set the output git_filter_list to NULL
+ * if no filters are requested for the given file.
+ *
+ * @param filters Output newly created git_filter_list (or NULL)
+ * @param repo Repository object that contains `path`
+ * @param blob The blob to which the filter will be applied (if known)
+ * @param path Relative path of the file to be filtered
+ * @param mode Filtering direction (WT->ODB or ODB->WT)
+ * @param opts The `git_filter_options` to use when loading filters
+ * @return 0 on success (which could still return NULL if no filters are
+ * needed for the requested file), <0 on error
+ */
+GIT_EXTERN(int) git_filter_list_load_ext(
+ git_filter_list **filters,
+ git_repository *repo,
+ git_blob *blob,
+ const char *path,
+ git_filter_mode_t mode,
+ git_filter_options *opts);
+
+/**
* Query the filter list to see if a given filter (by name) will run.
* The built-in filters "crlf" and "ident" can be queried, otherwise this
* is the name of the filter specified by the filter attribute.