summaryrefslogtreecommitdiff
path: root/src/blob.c
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2021-07-22 15:29:54 -0400
committerEdward Thomson <ethomson@edwardthomson.com>2021-07-22 16:40:42 -0400
commit1439b9ff05524949b6b3fa6cad716a9bb3cbc249 (patch)
treef415113d2ad056afda7ed9237d6cf9dbd73df72a /src/blob.c
parent0bd547a8bee02bf984ea5c7acdc8172044fcb3a4 (diff)
downloadlibgit2-1439b9ff05524949b6b3fa6cad716a9bb3cbc249.tar.gz
filter: introduce GIT_BLOB_FILTER_ATTRIBUTES_FROM_COMMIT
Provide a mechanism to filter using attribute data from a specific commit (making use of `GIT_ATTR_CHECK_INCLUDE_COMMIT`).
Diffstat (limited to 'src/blob.c')
-rw-r--r--src/blob.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/blob.c b/src/blob.c
index 169e34503..01ebf075e 100644
--- a/src/blob.c
+++ b/src/blob.c
@@ -421,7 +421,7 @@ int git_blob_filter(
int error = 0;
git_filter_list *fl = NULL;
git_blob_filter_options opts = GIT_BLOB_FILTER_OPTIONS_INIT;
- git_filter_flag_t flags = GIT_FILTER_DEFAULT;
+ git_filter_options filter_opts = GIT_FILTER_OPTIONS_INIT;
GIT_ASSERT_ARG(blob);
GIT_ASSERT_ARG(path);
@@ -441,14 +441,19 @@ int git_blob_filter(
return 0;
if ((opts.flags & GIT_BLOB_FILTER_NO_SYSTEM_ATTRIBUTES) != 0)
- flags |= GIT_FILTER_NO_SYSTEM_ATTRIBUTES;
+ filter_opts.flags |= GIT_FILTER_NO_SYSTEM_ATTRIBUTES;
if ((opts.flags & GIT_BLOB_FILTER_ATTRIBUTES_FROM_HEAD) != 0)
- flags |= GIT_FILTER_ATTRIBUTES_FROM_HEAD;
+ filter_opts.flags |= GIT_FILTER_ATTRIBUTES_FROM_HEAD;
- if (!(error = git_filter_list_load(
+ if ((opts.flags & GIT_BLOB_FILTER_ATTRIBUTES_FROM_COMMIT) != 0) {
+ filter_opts.flags |= GIT_FILTER_ATTRIBUTES_FROM_COMMIT;
+ filter_opts.commit_id = opts.commit_id;
+ }
+
+ if (!(error = git_filter_list_load_ext(
&fl, git_blob_owner(blob), blob, path,
- GIT_FILTER_TO_WORKTREE, flags))) {
+ GIT_FILTER_TO_WORKTREE, &filter_opts))) {
error = git_filter_list_apply_to_blob(out, fl, blob);