dir.c: factor out parts of last_exclude_matching for later reuse
Signed-off-by: Karsten Blees <blees@dcon.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Karsten Blees committed
Apr 15, 2013 at 21:11 UTC
46aa2f95d2fa79164fb0f5ad79bdd1d26fe689ea
1 file changed
+22
-14
dir.c
+22
-14
@@ -795,6 +795,26 @@ int is_excluded_from_list(const char *pathname,
795
return -1; /* undecided */
796
}
797
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
+
818
/*
819
* Loads the exclude lists for the directory containing pathname, then
820
* scans all exclude lists to determine whether pathname is excluded.
@@ -806,25 +826,13 @@ static struct exclude *last_exclude_matching(struct dir_struct *dir,
826
int *dtype_p)
827
{
828
int pathlen = strlen(pathname);
809
- int i, j;
810
- struct exclude_list_group *group;
811
- struct exclude *exclude;
829
const char *basename = strrchr(pathname, '/');
830
basename = (basename) ? basename+1 : pathname;
831
832
prep_exclude(dir, pathname, basename-pathname);
833
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);
836
}
837
838
/*