Extract a function collect_all_attrs()
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
a872701755
commit
2d72174492
17
attr.c
17
attr.c
@ -713,20 +713,31 @@ static int macroexpand_one(int attr_nr, int rem)
|
|||||||
return rem;
|
return rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
int git_checkattr(const char *path, int num, struct git_attr_check *check)
|
/*
|
||||||
|
* Collect all attributes for path into the array pointed to by
|
||||||
|
* check_all_attr.
|
||||||
|
*/
|
||||||
|
static void collect_all_attrs(const char *path)
|
||||||
{
|
{
|
||||||
struct attr_stack *stk;
|
struct attr_stack *stk;
|
||||||
int pathlen, i, rem;
|
int i, pathlen, rem;
|
||||||
|
|
||||||
bootstrap_attr_stack();
|
bootstrap_attr_stack();
|
||||||
|
prepare_attr_stack(path);
|
||||||
for (i = 0; i < attr_nr; i++)
|
for (i = 0; i < attr_nr; i++)
|
||||||
check_all_attr[i].value = ATTR__UNKNOWN;
|
check_all_attr[i].value = ATTR__UNKNOWN;
|
||||||
|
|
||||||
pathlen = strlen(path);
|
pathlen = strlen(path);
|
||||||
prepare_attr_stack(path);
|
|
||||||
rem = attr_nr;
|
rem = attr_nr;
|
||||||
for (stk = attr_stack; 0 < rem && stk; stk = stk->prev)
|
for (stk = attr_stack; 0 < rem && stk; stk = stk->prev)
|
||||||
rem = fill(path, pathlen, stk, rem);
|
rem = fill(path, pathlen, stk, rem);
|
||||||
|
}
|
||||||
|
|
||||||
|
int git_checkattr(const char *path, int num, struct git_attr_check *check)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
collect_all_attrs(path);
|
||||||
|
|
||||||
for (i = 0; i < num; i++) {
|
for (i = 0; i < num; i++) {
|
||||||
const char *value = check_all_attr[check[i].attr->attr_nr].value;
|
const char *value = check_all_attr[check[i].attr->attr_nr].value;
|
||||||
|
Reference in New Issue
Block a user