Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 78e16c3

Browse files
committed
Merge pull request libgit2#3597 from ethomson/filter_registration
Filter registration
2 parents b643501 + 82abd40 commit 78e16c3

File tree

7 files changed

+370
-304
lines changed

7 files changed

+370
-304
lines changed

include/git2/sys/filter.h

Lines changed: 34 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -127,17 +127,6 @@ GIT_EXTERN(git_filter_mode_t) git_filter_source_mode(const git_filter_source *sr
127127
*/
128128
GIT_EXTERN(uint32_t) git_filter_source_flags(const git_filter_source *src);
129129

130-
/*
131-
* struct git_filter
132-
*
133-
* The filter lifecycle:
134-
* - initialize - first use of filter
135-
* - shutdown - filter removed/unregistered from system
136-
* - check - considering filter for file
137-
* - apply - apply filter to file contents
138-
* - cleanup - done with file
139-
*/
140-
141130
/**
142131
* Initialize callback on filter
143132
*
@@ -233,31 +222,51 @@ typedef void (*git_filter_cleanup_fn)(
233222
* To associate extra data with a filter, allocate extra data and put the
234223
* `git_filter` struct at the start of your data buffer, then cast the
235224
* `self` pointer to your larger structure when your callback is invoked.
236-
*
237-
* `version` should be set to GIT_FILTER_VERSION
238-
*
239-
* `attributes` is a whitespace-separated list of attribute names to check
240-
* for this filter (e.g. "eol crlf text"). If the attribute name is bare,
241-
* it will be simply loaded and passed to the `check` callback. If it has
242-
* a value (i.e. "name=value"), the attribute must match that value for
243-
* the filter to be applied. The value may be a wildcard (eg, "name=*"),
244-
* in which case the filter will be invoked for any value for the given
245-
* attribute name. See the attribute parameter of the `check` callback
246-
* for the attribute value that was specified.
247-
*
248-
* The `initialize`, `shutdown`, `check`, `apply`, and `cleanup` callbacks
249-
* are all documented above with the respective function pointer typedefs.
250225
*/
251226
struct git_filter {
227+
/** The `version` field should be set to `GIT_FILTER_VERSION`. */
252228
unsigned int version;
253229

230+
/**
231+
* A whitespace-separated list of attribute names to check for this
232+
* filter (e.g. "eol crlf text"). If the attribute name is bare, it
233+
* will be simply loaded and passed to the `check` callback. If it
234+
* has a value (i.e. "name=value"), the attribute must match that
235+
* value for the filter to be applied. The value may be a wildcard
236+
* (eg, "name=*"), in which case the filter will be invoked for any
237+
* value for the given attribute name. See the attribute parameter
238+
* of the `check` callback for the attribute value that was specified.
239+
*/
254240
const char *attributes;
255241

242+
/** Called when the filter is first used for any file. */
256243
git_filter_init_fn initialize;
244+
245+
/** Called when the filter is removed or unregistered from the system. */
257246
git_filter_shutdown_fn shutdown;
247+
248+
/**
249+
* Called to determine whether the filter should be invoked for a
250+
* given file. If this function returns `GIT_PASSTHROUGH` then the
251+
* `apply` function will not be invoked and the contents will be passed
252+
* through unmodified.
253+
*/
258254
git_filter_check_fn check;
255+
256+
/**
257+
* Called to actually apply the filter to file contents. If this
258+
* function returns `GIT_PASSTHROUGH` then the contents will be passed
259+
* through unmodified.
260+
*/
259261
git_filter_apply_fn apply;
262+
263+
/**
264+
* Called to apply the filter in a streaming manner. If this is not
265+
* specified then the system will call `apply` with the whole buffer.
266+
*/
260267
git_filter_stream_fn stream;
268+
269+
/** Called when the system is done filtering for a file. */
261270
git_filter_cleanup_fn cleanup;
262271
};
263272

0 commit comments

Comments
 (0)