summaryrefslogtreecommitdiff
path: root/include/git2
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@microsoft.com>2015-01-22 16:10:06 -0600
committerEdward Thomson <ethomson@microsoft.com>2015-02-17 02:19:05 -0500
commitfbdc9db3643e89e26d6e49f7b4e4ec1c668a4f0d (patch)
tree5658b262c790c12a64ac6d153fdd92f44b65fbbc /include/git2
parent437ba9ad651a395b8b3105f5a2d2848194166c06 (diff)
downloadlibgit2-fbdc9db3643e89e26d6e49f7b4e4ec1c668a4f0d.tar.gz
filters: introduce streaming filters
Add structures and preliminary functions to take a buffer, file or blob and write the contents in chunks through an arbitrary number of chained filters, finally writing into a user-provided function accept the contents.
Diffstat (limited to 'include/git2')
-rw-r--r--include/git2/filter.h16
-rw-r--r--include/git2/sys/filter.h14
-rw-r--r--include/git2/types.h3
3 files changed, 33 insertions, 0 deletions
diff --git a/include/git2/filter.h b/include/git2/filter.h
index 5b3f40394..600356c71 100644
--- a/include/git2/filter.h
+++ b/include/git2/filter.h
@@ -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_filter_stream *target);
+
+GIT_EXTERN(int) git_filter_list_stream_file(
+ git_filter_list *filters,
+ git_repository *repo,
+ const char *path,
+ git_filter_stream *target);
+
+GIT_EXTERN(int) git_filter_list_stream_blob(
+ git_filter_list *filters,
+ git_blob *blob,
+ git_filter_stream *target);
+
/**
* Free a git_filter_list
*
diff --git a/include/git2/sys/filter.h b/include/git2/sys/filter.h
index 60248271a..cc06c54ad 100644
--- a/include/git2/sys/filter.h
+++ b/include/git2/sys/filter.h
@@ -208,6 +208,19 @@ typedef int (*git_filter_apply_fn)(
const git_buf *from,
const git_filter_source *src);
+struct git_filter_stream {
+ int (*write)(git_filter_stream *stream, const char *buffer, size_t len);
+ int (*close)(git_filter_stream *stream);
+ void (*free)(git_filter_stream *stream);
+};
+
+typedef int (*git_filter_stream_fn)(
+ git_filter_stream **out,
+ git_filter *self,
+ void **payload,
+ const git_filter_source *src,
+ git_filter_stream *next);
+
/**
* Callback to clean up after filtering has been applied
*
@@ -247,6 +260,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..3ed97d189 100644
--- a/include/git2/types.h
+++ b/include/git2/types.h
@@ -410,6 +410,9 @@ typedef enum {
GIT_SUBMODULE_RECURSE_ONDEMAND = 2,
} git_submodule_recurse_t;
+/** A stream to write filters. */
+typedef struct git_filter_stream git_filter_stream;
+
/** @} */
GIT_END_DECL