Skip to content

Commit a5392ea

Browse files
committed
blob: allow blob filtering to ignore system gitattributes
Introduce `GIT_BLOB_FILTER_NO_SYSTEM_ATTRIBUTES`, which tells `git_blob_filter` to ignore the system-wide attributes file, usually `/etc/gitattributes`. This simply passes the appropriate flag to the attribute loading code.
1 parent 22eb12a commit a5392ea

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

include/git2/blob.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,12 @@ GIT_EXTERN(git_off_t) git_blob_rawsize(const git_blob *blob);
102102
typedef enum {
103103
/** When set, filters will not be applied to binary files. */
104104
GIT_BLOB_FILTER_CHECK_FOR_BINARY = (1 << 0),
105+
106+
/**
107+
* When set, filters will not load configuration from the
108+
* system-wide `gitattributes` in `/etc` (or system equivalent).
109+
*/
110+
GIT_BLOB_FILTER_NO_SYSTEM_ATTRIBUTES = (1 << 1),
105111
} git_blob_filter_flag_t;
106112

107113
/**

src/blob.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,9 @@ int git_blob_filter(
425425
git_blob_is_binary(blob))
426426
return 0;
427427

428+
if ((opts.flags & GIT_BLOB_FILTER_NO_SYSTEM_ATTRIBUTES) != 0)
429+
flags |= GIT_FILTER_NO_SYSTEM_ATTRIBUTES;
430+
428431
if (!(error = git_filter_list_load(
429432
&fl, git_blob_owner(blob), blob, path,
430433
GIT_FILTER_TO_WORKTREE, flags))) {

0 commit comments

Comments
 (0)