diff options
author | Russell Belfer <rb@github.com> | 2013-09-11 16:38:33 -0700 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2013-09-17 09:31:45 -0700 |
commit | 4b11f25a4fbb6952284e037a70e2d61fde841ab6 (patch) | |
tree | 41929ce26c3c41183b3fc221927afb67444eadf2 /include/git2 | |
parent | 40cb40fab93281c808255d980bbe81a18a4d9e9a (diff) | |
download | libgit2-4b11f25a4fbb6952284e037a70e2d61fde841ab6.tar.gz |
Add ident filter
This adds the ident filter (that knows how to replace $Id$) and
tweaks the filter APIs and code so that git_filter_source objects
actually have the updated OID of the object being filtered when
it is a known value.
Diffstat (limited to 'include/git2')
-rw-r--r-- | include/git2/filter.h | 6 | ||||
-rw-r--r-- | include/git2/sys/filter.h | 11 |
2 files changed, 13 insertions, 4 deletions
diff --git a/include/git2/filter.h b/include/git2/filter.h index 8ef88d81b..649ed97cf 100644 --- a/include/git2/filter.h +++ b/include/git2/filter.h @@ -42,11 +42,13 @@ typedef enum { * file data. Libgit2 includes one built in filter and it is possible to * write your own (see git2/sys/filter.h for information on that). * - * The built in filter is: + * The two builtin filters are: * * * "crlf" which uses the complex rules with the "text", "eol", and * "crlf" file attributes to decide how to convert between LF and CRLF * line endings + * * "ident" which replaces "$Id$" in a blob with "$Id: <blob OID>$" upon + * checkout and replaced "$Id: <anything>$" with "$Id$" on checkin. */ typedef struct git_filter git_filter; @@ -70,6 +72,7 @@ typedef struct git_filter_list git_filter_list; * * @param filters Output newly created git_filter_list (or NULL) * @param repo Repository object that contains `path` + * @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) * @return 0 on success (which could still return NULL if no filters are @@ -78,6 +81,7 @@ typedef struct git_filter_list git_filter_list; GIT_EXTERN(int) git_filter_list_load( git_filter_list **filters, git_repository *repo, + git_blob *blob, /* can be NULL */ const char *path, git_filter_mode_t mode); diff --git a/include/git2/sys/filter.h b/include/git2/sys/filter.h index ca5738a53..c35fe55f6 100644 --- a/include/git2/sys/filter.h +++ b/include/git2/sys/filter.h @@ -26,7 +26,11 @@ GIT_BEGIN_DECL */ GIT_EXTERN(git_filter *) git_filter_lookup(const char *name); -#define GIT_FILTER_CRLF "crlf" +#define GIT_FILTER_CRLF "crlf" +#define GIT_FILTER_IDENT "ident" + +#define GIT_FILTER_CRLF_PRIORITY 0 +#define GIT_FILTER_IDENT_PRIORITY 100 /** * Create a new empty filter list @@ -199,8 +203,9 @@ struct git_filter { * issued in order of `priority` on smudge (to workdir), and in reverse * order of `priority` on clean (to odb). * - * One filter will be preregistered with libgit2: - * - GIT_FILTER_CRLF with priority of 0. + * 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 |