summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrandon Williams <bmwill@google.com>2017-01-28 02:01:59 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-02-01 21:46:52 (GMT)
commit6bc2e3f709d04e416f3b5d1e23f2ac31f4cbc1d1 (patch)
treefbb763b5006ae1e94aa8b0d9cae29609edf3b9fa
parent1295c2152457c2267d605d353332ae4b3e5e5d5c (diff)
downloadgit-6bc2e3f709d04e416f3b5d1e23f2ac31f4cbc1d1.zip
git-6bc2e3f709d04e416f3b5d1e23f2ac31f4cbc1d1.tar.gz
git-6bc2e3f709d04e416f3b5d1e23f2ac31f4cbc1d1.tar.bz2
attr: pass struct attr_check to collect_some_attrs
The old callchain used to take an array of attr_check_item items. Instead pass the 'attr_check' container object to 'collect_some_attrs()' and access the fields in the data structure directly. Signed-off-by: Brandon Williams <bmwill@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--attr.c33
1 files changed, 13 insertions, 20 deletions
diff --git a/attr.c b/attr.c
index c0e7893..81a3c74 100644
--- a/attr.c
+++ b/attr.c
@@ -846,9 +846,7 @@ static int macroexpand_one(int nr, int rem)
* check_all_attr. If num is non-zero, only attributes in check[] are
* collected. Otherwise all attributes are collected.
*/
-static void collect_some_attrs(const char *path, int num,
- struct attr_check_item *check)
-
+static void collect_some_attrs(const char *path, struct attr_check *check)
{
struct attr_stack *stk;
int i, pathlen, rem, dirlen;
@@ -871,17 +869,18 @@ static void collect_some_attrs(const char *path, int num,
prepare_attr_stack(path, dirlen);
for (i = 0; i < attr_nr; i++)
check_all_attr[i].value = ATTR__UNKNOWN;
- if (num && !cannot_trust_maybe_real) {
+ if (check->nr && !cannot_trust_maybe_real) {
rem = 0;
- for (i = 0; i < num; i++) {
- if (!check[i].attr->maybe_real) {
+ for (i = 0; i < check->nr; i++) {
+ const struct git_attr *a = check->items[i].attr;
+ if (!a->maybe_real) {
struct attr_check_item *c;
- c = check_all_attr + check[i].attr->attr_nr;
+ c = check_all_attr + a->attr_nr;
c->value = ATTR__UNSET;
rem++;
}
}
- if (rem == num)
+ if (rem == check->nr)
return;
}
@@ -890,18 +889,17 @@ static void collect_some_attrs(const char *path, int num,
rem = fill(path, pathlen, basename_offset, stk, rem);
}
-static int git_check_attrs(const char *path, int num,
- struct attr_check_item *check)
+int git_check_attr(const char *path, struct attr_check *check)
{
int i;
- collect_some_attrs(path, num, check);
+ collect_some_attrs(path, check);
- for (i = 0; i < num; i++) {
- const char *value = check_all_attr[check[i].attr->attr_nr].value;
+ for (i = 0; i < check->nr; i++) {
+ const char *value = check_all_attr[check->items[i].attr->attr_nr].value;
if (value == ATTR__UNKNOWN)
value = ATTR__UNSET;
- check[i].value = value;
+ check->items[i].value = value;
}
return 0;
@@ -912,7 +910,7 @@ void git_all_attrs(const char *path, struct attr_check *check)
int i;
attr_check_reset(check);
- collect_some_attrs(path, check->nr, check->items);
+ collect_some_attrs(path, check);
for (i = 0; i < attr_nr; i++) {
const char *name = check_all_attr[i].attr->name;
@@ -925,11 +923,6 @@ void git_all_attrs(const char *path, struct attr_check *check)
}
}
-int git_check_attr(const char *path, struct attr_check *check)
-{
- return git_check_attrs(path, check->nr, check->items);
-}
-
void git_attr_set_direction(enum git_attr_direction new, struct index_state *istate)
{
enum git_attr_direction old = direction;