libgit2

git_filter_register

Version:

Register a filter under a given name with a given priority.

As mentioned elsewhere, the initialize callback will not be invoked immediately. It is deferred until the filter is used in some way.

A filter's attribute checks and check and apply callbacks will be issued in order of priority on smudge (to workdir), and in reverse order of priority on clean (to odb).

Two filters are preregistered with libgit2:

  • GIT_FILTER_CRLF with priority 0
  • GIT_FILTER_IDENT with priority 100

Currently the filter registry is not thread safe, so any registering or deregistering of filters must be done outside of any possible usage of the filters (i.e. during application setup or shutdown).

Signature

int git_filter_register(const char *name, git_filter *filter, int priority);

Parameters

const char *
In
name

A name by which the filter can be referenced. Attempting to register with an in-use name will return GIT_EEXISTS.

In
filter

The filter definition. This pointer will be stored as is by libgit2 so it must be a durable allocation (either static or on the heap).

int
In
priority

The priority for filter application

Returns

int

0 on successful registry, error code < 0 on failure

Versions