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>
Brandon Williams committed
Jan 27, 2017 at 18:01 UTC
6bc2e3f709d04e416f3b5d1e23f2ac31f4cbc1d1
1 file changed
+13
-20
attr.c
+13
-20
@@ -846,9 +846,7 @@ static int macroexpand_one(int nr, int rem)
846
* check_all_attr. If num is non-zero, only attributes in check[] are
847
* collected. Otherwise all attributes are collected.
848
*/
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)
850
{
851
struct attr_stack *stk;
852
int i, pathlen, rem, dirlen;
@@ -871,17 +869,18 @@ static void collect_some_attrs(const char *path, int num,
869
prepare_attr_stack(path, dirlen);
870
for (i = 0; i < attr_nr; i++)
871
check_all_attr[i].value = ATTR__UNKNOWN;
874
- if (num && !cannot_trust_maybe_real) {
872
+ if (check->nr && !cannot_trust_maybe_real) {
873
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) {
877
struct attr_check_item *c;
879
- c = check_all_attr + check[i].attr->attr_nr;
878
+ c = check_all_attr + a->attr_nr;
879
c->value = ATTR__UNSET;
880
rem++;
881
}
882
}
884
- if (rem == num)
883
+ if (rem == check->nr)
884
return;
885
}
886
@@ -890,18 +889,17 @@ static void collect_some_attrs(const char *path, int num,
889
rem = fill(path, pathlen, basename_offset, stk, rem);
890
}
891
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)
893
{
894
int i;
895
898
- collect_some_attrs(path, num, check);
896
+ collect_some_attrs(path, check);
897
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;
900
if (value == ATTR__UNKNOWN)
901
value = ATTR__UNSET;
904
- check[i].value = value;
902
+ check->items[i].value = value;
903
}
904
905
return 0;
@@ -912,7 +910,7 @@ void git_all_attrs(const char *path, struct attr_check *check)
910
int i;
911
912
attr_check_reset(check);
915
- collect_some_attrs(path, check->nr, check->items);
913
+ collect_some_attrs(path, check);
914
915
for (i = 0; i < attr_nr; i++) {
916
const char *name = check_all_attr[i].attr->name;
@@ -925,11 +923,6 @@ void git_all_attrs(const char *path, struct attr_check *check)
923
}
924
}
925
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
-
926
void git_attr_set_direction(enum git_attr_direction new, struct index_state *istate)
927
{
928
enum git_attr_direction old = direction;