diff options
author | Russell Belfer <rb@github.com> | 2013-09-09 16:57:34 -0700 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2013-09-17 09:31:44 -0700 |
commit | 974774c7b00c08585b05ff87174872be005a1f29 (patch) | |
tree | cea2a1d9b29a4601b90fe23a47775eb39773dcb5 /src/attr.c | |
parent | 570ba25cb0f757f993e06df629faced32fdf2f8f (diff) | |
download | libgit2-974774c7b00c08585b05ff87174872be005a1f29.tar.gz |
Add attributes to filters and fix registry
The filter registry as implemented was too primitive to actually
work once multiple filters were coming into play. This expands
the implementation of the registry to handle multiple prioritized
filters correctly.
Additionally, this adds an "attributes" field to a filter that
makes it really really easy to implement filters that are based
on one or more attribute values. The lookup and even simple value
checking can all happen automatically without custom filter code.
Lastly, with the registry improvements, this fills out the filter
lifecycle callbacks, with initialize and shutdown callbacks that
will be called before the filter is first used and after it is
last invoked. This allows for system-wide initialization and
cleanup by the filter.
Diffstat (limited to 'src/attr.c')
-rw-r--r-- | src/attr.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/attr.c b/src/attr.c index 6cdff29f9..7946db4d6 100644 --- a/src/attr.c +++ b/src/attr.c @@ -26,7 +26,6 @@ git_attr_t git_attr_value(const char *attr) return GIT_ATTR_VALUE_T; } - static int collect_attr_files( git_repository *repo, uint32_t flags, @@ -103,8 +102,6 @@ int git_attr_get_many( attr_get_many_info *info = NULL; size_t num_found = 0; - memset((void *)values, 0, sizeof(const char *) * num_attr); - if (git_attr_path__init(&path, pathname, git_repository_workdir(repo)) < 0) return -1; @@ -141,6 +138,11 @@ int git_attr_get_many( } } + for (k = 0; k < num_attr; k++) { + if (!info[k].found) + values[k] = NULL; + } + cleanup: git_vector_free(&files); git_attr_path__free(&path); |