Skip to content

Commit 35a94d4

Browse files
pcloudsgitster
authored andcommitted
Unindent excluded_from_list()
Return early if el->nr == 0. Unindent one more level for FNM_PATHNAME code block as this block is getting complex and may need more indentation. Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent befc5ed commit 35a94d4

File tree

1 file changed

+48
-48
lines changed

1 file changed

+48
-48
lines changed

dir.c

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -498,56 +498,56 @@ int excluded_from_list(const char *pathname,
498498
{
499499
int i;
500500

501-
if (el->nr) {
502-
for (i = el->nr - 1; 0 <= i; i--) {
503-
struct exclude *x = el->excludes[i];
504-
const char *exclude = x->pattern;
505-
int to_exclude = x->to_exclude;
506-
507-
if (x->flags & EXC_FLAG_MUSTBEDIR) {
508-
if (*dtype == DT_UNKNOWN)
509-
*dtype = get_dtype(NULL, pathname, pathlen);
510-
if (*dtype != DT_DIR)
511-
continue;
512-
}
501+
if (!el->nr)
502+
return -1; /* undefined */
503+
504+
for (i = el->nr - 1; 0 <= i; i--) {
505+
struct exclude *x = el->excludes[i];
506+
const char *exclude = x->pattern;
507+
int to_exclude = x->to_exclude;
508+
509+
if (x->flags & EXC_FLAG_MUSTBEDIR) {
510+
if (*dtype == DT_UNKNOWN)
511+
*dtype = get_dtype(NULL, pathname, pathlen);
512+
if (*dtype != DT_DIR)
513+
continue;
514+
}
513515

514-
if (x->flags & EXC_FLAG_NODIR) {
515-
/* match basename */
516-
if (x->flags & EXC_FLAG_NOWILDCARD) {
517-
if (!strcmp_icase(exclude, basename))
518-
return to_exclude;
519-
} else if (x->flags & EXC_FLAG_ENDSWITH) {
520-
if (x->patternlen - 1 <= pathlen &&
521-
!strcmp_icase(exclude + 1, pathname + pathlen - x->patternlen + 1))
522-
return to_exclude;
523-
} else {
524-
if (fnmatch_icase(exclude, basename, 0) == 0)
525-
return to_exclude;
526-
}
527-
}
528-
else {
529-
/* match with FNM_PATHNAME:
530-
* exclude has base (baselen long) implicitly
531-
* in front of it.
532-
*/
533-
int baselen = x->baselen;
534-
if (*exclude == '/')
535-
exclude++;
536-
537-
if (pathlen < baselen ||
538-
(baselen && pathname[baselen-1] != '/') ||
539-
strncmp_icase(pathname, x->base, baselen))
540-
continue;
541-
542-
if (x->flags & EXC_FLAG_NOWILDCARD) {
543-
if (!strcmp_icase(exclude, pathname + baselen))
544-
return to_exclude;
545-
} else {
546-
if (fnmatch_icase(exclude, pathname+baselen,
547-
FNM_PATHNAME) == 0)
548-
return to_exclude;
549-
}
516+
if (x->flags & EXC_FLAG_NODIR) {
517+
/* match basename */
518+
if (x->flags & EXC_FLAG_NOWILDCARD) {
519+
if (!strcmp_icase(exclude, basename))
520+
return to_exclude;
521+
} else if (x->flags & EXC_FLAG_ENDSWITH) {
522+
if (x->patternlen - 1 <= pathlen &&
523+
!strcmp_icase(exclude + 1, pathname + pathlen - x->patternlen + 1))
524+
return to_exclude;
525+
} else {
526+
if (fnmatch_icase(exclude, basename, 0) == 0)
527+
return to_exclude;
550528
}
529+
continue;
530+
}
531+
532+
533+
/* match with FNM_PATHNAME:
534+
* exclude has base (baselen long) implicitly in front of it.
535+
*/
536+
if (*exclude == '/')
537+
exclude++;
538+
539+
if (pathlen < x->baselen ||
540+
(x->baselen && pathname[x->baselen-1] != '/') ||
541+
strncmp_icase(pathname, x->base, x->baselen))
542+
continue;
543+
544+
if (x->flags & EXC_FLAG_NOWILDCARD) {
545+
if (!strcmp_icase(exclude, pathname + x->baselen))
546+
return to_exclude;
547+
} else {
548+
if (fnmatch_icase(exclude, pathname+x->baselen,
549+
FNM_PATHNAME) == 0)
550+
return to_exclude;
551551
}
552552
}
553553
return -1; /* undecided */

0 commit comments

Comments
 (0)