Skip to content

Commit 6bc2e3f

Browse files
bmwillgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1295c21 commit 6bc2e3f

File tree

1 file changed

+13
-20
lines changed

1 file changed

+13
-20
lines changed

attr.c

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -846,9 +846,7 @@ static int macroexpand_one(int nr, int rem)
846846
* check_all_attr. If num is non-zero, only attributes in check[] are
847847
* collected. Otherwise all attributes are collected.
848848
*/
849-
static void collect_some_attrs(const char *path, int num,
850-
struct attr_check_item *check)
851-
849+
static void collect_some_attrs(const char *path, struct attr_check *check)
852850
{
853851
struct attr_stack *stk;
854852
int i, pathlen, rem, dirlen;
@@ -871,17 +869,18 @@ static void collect_some_attrs(const char *path, int num,
871869
prepare_attr_stack(path, dirlen);
872870
for (i = 0; i < attr_nr; i++)
873871
check_all_attr[i].value = ATTR__UNKNOWN;
874-
if (num && !cannot_trust_maybe_real) {
872+
if (check->nr && !cannot_trust_maybe_real) {
875873
rem = 0;
876-
for (i = 0; i < num; i++) {
877-
if (!check[i].attr->maybe_real) {
874+
for (i = 0; i < check->nr; i++) {
875+
const struct git_attr *a = check->items[i].attr;
876+
if (!a->maybe_real) {
878877
struct attr_check_item *c;
879-
c = check_all_attr + check[i].attr->attr_nr;
878+
c = check_all_attr + a->attr_nr;
880879
c->value = ATTR__UNSET;
881880
rem++;
882881
}
883882
}
884-
if (rem == num)
883+
if (rem == check->nr)
885884
return;
886885
}
887886

@@ -890,18 +889,17 @@ static void collect_some_attrs(const char *path, int num,
890889
rem = fill(path, pathlen, basename_offset, stk, rem);
891890
}
892891

893-
static int git_check_attrs(const char *path, int num,
894-
struct attr_check_item *check)
892+
int git_check_attr(const char *path, struct attr_check *check)
895893
{
896894
int i;
897895

898-
collect_some_attrs(path, num, check);
896+
collect_some_attrs(path, check);
899897

900-
for (i = 0; i < num; i++) {
901-
const char *value = check_all_attr[check[i].attr->attr_nr].value;
898+
for (i = 0; i < check->nr; i++) {
899+
const char *value = check_all_attr[check->items[i].attr->attr_nr].value;
902900
if (value == ATTR__UNKNOWN)
903901
value = ATTR__UNSET;
904-
check[i].value = value;
902+
check->items[i].value = value;
905903
}
906904

907905
return 0;
@@ -912,7 +910,7 @@ void git_all_attrs(const char *path, struct attr_check *check)
912910
int i;
913911

914912
attr_check_reset(check);
915-
collect_some_attrs(path, check->nr, check->items);
913+
collect_some_attrs(path, check);
916914

917915
for (i = 0; i < attr_nr; i++) {
918916
const char *name = check_all_attr[i].attr->name;
@@ -925,11 +923,6 @@ void git_all_attrs(const char *path, struct attr_check *check)
925923
}
926924
}
927925

928-
int git_check_attr(const char *path, struct attr_check *check)
929-
{
930-
return git_check_attrs(path, check->nr, check->items);
931-
}
932-
933926
void git_attr_set_direction(enum git_attr_direction new, struct index_state *istate)
934927
{
935928
enum git_attr_direction old = direction;

0 commit comments

Comments
 (0)