Skip to content

Commit

Permalink
attr: pass struct attr_check to collect_some_attrs
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
bmwill authored and gitster committed Feb 1, 2017
1 parent 1295c21 commit 6bc2e3f
Showing 1 changed file with 13 additions and 20 deletions.
33 changes: 13 additions & 20 deletions attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}

Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 6bc2e3f

Please sign in to comment.