Skip to content

Commit 46aa2f9

Browse files
kbleesgitster
authored andcommitted
dir.c: factor out parts of last_exclude_matching for later reuse
Signed-off-by: Karsten Blees <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5bd8e2d commit 46aa2f9

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

dir.c

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,26 @@ int is_excluded_from_list(const char *pathname,
795795
return -1; /* undecided */
796796
}
797797

798+
static struct exclude *last_exclude_matching_from_lists(struct dir_struct *dir,
799+
const char *pathname, int pathlen, const char *basename,
800+
int *dtype_p)
801+
{
802+
int i, j;
803+
struct exclude_list_group *group;
804+
struct exclude *exclude;
805+
for (i = EXC_CMDL; i <= EXC_FILE; i++) {
806+
group = &dir->exclude_list_group[i];
807+
for (j = group->nr - 1; j >= 0; j--) {
808+
exclude = last_exclude_matching_from_list(
809+
pathname, pathlen, basename, dtype_p,
810+
&group->el[j]);
811+
if (exclude)
812+
return exclude;
813+
}
814+
}
815+
return NULL;
816+
}
817+
798818
/*
799819
* Loads the exclude lists for the directory containing pathname, then
800820
* scans all exclude lists to determine whether pathname is excluded.
@@ -806,25 +826,13 @@ static struct exclude *last_exclude_matching(struct dir_struct *dir,
806826
int *dtype_p)
807827
{
808828
int pathlen = strlen(pathname);
809-
int i, j;
810-
struct exclude_list_group *group;
811-
struct exclude *exclude;
812829
const char *basename = strrchr(pathname, '/');
813830
basename = (basename) ? basename+1 : pathname;
814831

815832
prep_exclude(dir, pathname, basename-pathname);
816833

817-
for (i = EXC_CMDL; i <= EXC_FILE; i++) {
818-
group = &dir->exclude_list_group[i];
819-
for (j = group->nr - 1; j >= 0; j--) {
820-
exclude = last_exclude_matching_from_list(
821-
pathname, pathlen, basename, dtype_p,
822-
&group->el[j]);
823-
if (exclude)
824-
return exclude;
825-
}
826-
}
827-
return NULL;
834+
return last_exclude_matching_from_lists(dir, pathname, pathlen,
835+
basename, dtype_p);
828836
}
829837

830838
/*

0 commit comments

Comments
 (0)