libgit2

git_filter

Version:

Filter structure used to register custom filters.

To associate extra data with a filter, allocate extra data and put the git_filter struct at the start of your data buffer, then cast the self pointer to your larger structure when your callback is invoked.

Signature

typedef struct git_filter { unsigned int version const char *attributes git_filter_init_fn initialize 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 };

Members

unsigned int
version

The version field should be set to GIT_FILTER_VERSION.

const char *
attributes

A whitespace-separated list of attribute names to check for this filter (e.g. "eol crlf text"). If the attribute name is bare, it will be simply loaded and passed to the check callback. If it has a value (i.e. "name=value"), the attribute must match that value for the filter to be applied. The value may be a wildcard (eg, "name=*"), in which case the filter will be invoked for any value for the given attribute name. See the attribute parameter of the check callback for the attribute value that was specified.

initialize

Called when the filter is first used for any file.

shutdown

Called when the filter is removed or unregistered from the system.

check

Called to determine whether the filter should be invoked for a given file. If this function returns GIT_PASSTHROUGH then the stream or apply functions will not be invoked and the contents will be passed through unmodified.

apply

Provided for backward compatibility; this will apply the filter to the given contents in a git_buf. Callers should provide a stream function instead.

stream

Called to apply the filter, this function will provide a git_writestream that will the original data will be written to; with that data, the git_writestream will then perform the filter translation and stream the filtered data out to the next location.

cleanup

Called when the system is done filtering for a file.

Returned By

Parameter To

Versions