summaryrefslogtreecommitdiff
path: root/include/git2
diff options
context:
space:
mode:
Diffstat (limited to 'include/git2')
-rw-r--r--include/git2/filter.h26
-rw-r--r--include/git2/sys/filter.h12
-rw-r--r--include/git2/types.h9
3 files changed, 40 insertions, 7 deletions
diff --git a/include/git2/filter.h b/include/git2/filter.h
index 5b3f40394..dc59e6341 100644
--- a/include/git2/filter.h
+++ b/include/git2/filter.h
@@ -39,9 +39,9 @@ typedef enum {
* Filter option flags.
*/
typedef enum {
- GIT_FILTER_OPT_DEFAULT = 0u,
- GIT_FILTER_OPT_ALLOW_UNSAFE = (1u << 0),
-} git_filter_opt_t;
+ GIT_FILTER_DEFAULT = 0u,
+ GIT_FILTER_ALLOW_UNSAFE = (1u << 0),
+} git_filter_flag_t;
/**
* A filter that can transform file data
@@ -83,7 +83,7 @@ typedef struct git_filter_list git_filter_list;
* @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 options Combination of `git_filter_opt_t` flags
+ * @param flags Combination of `git_filter_flag_t` flags
* @return 0 on success (which could still return NULL if no filters are
* needed for the requested file), <0 on error
*/
@@ -93,7 +93,7 @@ GIT_EXTERN(int) git_filter_list_load(
git_blob *blob, /* can be NULL */
const char *path,
git_filter_mode_t mode,
- uint32_t options);
+ uint32_t flags);
/**
* Apply filter list to a data buffer.
@@ -137,6 +137,22 @@ GIT_EXTERN(int) git_filter_list_apply_to_blob(
git_filter_list *filters,
git_blob *blob);
+GIT_EXTERN(int) git_filter_list_stream_data(
+ git_filter_list *filters,
+ git_buf *data,
+ git_writestream *target);
+
+GIT_EXTERN(int) git_filter_list_stream_file(
+ git_filter_list *filters,
+ git_repository *repo,
+ const char *path,
+ git_writestream *target);
+
+GIT_EXTERN(int) git_filter_list_stream_blob(
+ git_filter_list *filters,
+ git_blob *blob,
+ git_writestream *target);
+
/**
* Free a git_filter_list
*
diff --git a/include/git2/sys/filter.h b/include/git2/sys/filter.h
index 60248271a..5fd8d5566 100644
--- a/include/git2/sys/filter.h
+++ b/include/git2/sys/filter.h
@@ -123,9 +123,9 @@ GIT_EXTERN(const git_oid *) git_filter_source_id(const git_filter_source *src);
GIT_EXTERN(git_filter_mode_t) git_filter_source_mode(const git_filter_source *src);
/**
- * Get the combination git_filter_opt_t options to be applied
+ * Get the combination git_filter_flag_t options to be applied
*/
-GIT_EXTERN(uint32_t) git_filter_source_options(const git_filter_source *src);
+GIT_EXTERN(uint32_t) git_filter_source_flags(const git_filter_source *src);
/*
* struct git_filter
@@ -208,6 +208,13 @@ typedef int (*git_filter_apply_fn)(
const git_buf *from,
const git_filter_source *src);
+typedef int (*git_filter_stream_fn)(
+ git_writestream **out,
+ git_filter *self,
+ void **payload,
+ const git_filter_source *src,
+ git_writestream *next);
+
/**
* Callback to clean up after filtering has been applied
*
@@ -247,6 +254,7 @@ struct git_filter {
git_filter_shutdown_fn shutdown;
git_filter_check_fn check;
git_filter_apply_fn apply;
+ git_filter_stream_fn stream;
git_filter_cleanup_fn cleanup;
};
diff --git a/include/git2/types.h b/include/git2/types.h
index 35e1573c7..c90ac4776 100644
--- a/include/git2/types.h
+++ b/include/git2/types.h
@@ -410,6 +410,15 @@ typedef enum {
GIT_SUBMODULE_RECURSE_ONDEMAND = 2,
} git_submodule_recurse_t;
+/** A type to write in a streaming fashion, for example, for filters. */
+typedef struct git_writestream git_writestream;
+
+struct git_writestream {
+ int (*write)(git_writestream *stream, const char *buffer, size_t len);
+ int (*close)(git_writestream *stream);
+ void (*free)(git_writestream *stream);
+};
+
/** @} */
GIT_END_DECL