Commit fba3bf79 by Edward Thomson

blob: optionally read attributes from repository

When `GIT_BLOB_FILTER_ATTTRIBUTES_FROM_HEAD` is passed to
`git_blob_filter`, read attributes from `gitattributes` files that
are checked in to the repository at the HEAD revision.  This passes
the flag `GIT_FILTER_ATTRIBUTES_FROM_HEAD` to the filter functions.
parent f0f27c1c
...@@ -108,6 +108,12 @@ typedef enum { ...@@ -108,6 +108,12 @@ typedef enum {
* system-wide `gitattributes` in `/etc` (or system equivalent). * system-wide `gitattributes` in `/etc` (or system equivalent).
*/ */
GIT_BLOB_FILTER_NO_SYSTEM_ATTRIBUTES = (1 << 1), GIT_BLOB_FILTER_NO_SYSTEM_ATTRIBUTES = (1 << 1),
/**
* When set, filters will be loaded from a `.gitattributes` file
* in the HEAD commit.
*/
GIT_BLOB_FILTER_ATTTRIBUTES_FROM_HEAD = (1 << 2),
} git_blob_filter_flag_t; } git_blob_filter_flag_t;
/** /**
......
...@@ -428,6 +428,9 @@ int git_blob_filter( ...@@ -428,6 +428,9 @@ int git_blob_filter(
if ((opts.flags & GIT_BLOB_FILTER_NO_SYSTEM_ATTRIBUTES) != 0) if ((opts.flags & GIT_BLOB_FILTER_NO_SYSTEM_ATTRIBUTES) != 0)
flags |= GIT_FILTER_NO_SYSTEM_ATTRIBUTES; flags |= GIT_FILTER_NO_SYSTEM_ATTRIBUTES;
if ((opts.flags & GIT_BLOB_FILTER_ATTTRIBUTES_FROM_HEAD) != 0)
flags |= GIT_FILTER_ATTRIBUTES_FROM_HEAD;
if (!(error = git_filter_list_load( if (!(error = git_filter_list_load(
&fl, git_blob_owner(blob), blob, path, &fl, git_blob_owner(blob), blob, path,
GIT_FILTER_TO_WORKTREE, flags))) { GIT_FILTER_TO_WORKTREE, flags))) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment