Skip to content

Commit 4ff89ee

Browse files
derrickstoleegitster
authored andcommitted
treewide: rename 'EXCL_FLAG_' to 'PATTERN_FLAG_'
The first consumer of pattern-matching filenames was the .gitignore feature. In that context, storing a list of patterns as a 'struct exclude_list' makes sense. However, the sparse-checkout feature then adopted these structures and methods, but with the opposite meaning: these patterns match the files that should be included! It would be clearer to rename this entire library as a "pattern matching" library, and the callers apply exclusion/inclusion logic accordingly based on their needs. This commit replaces 'EXCL_FLAG_' to 'PATTERN_FLAG_' in the names of the flags used on 'struct path_pattern'. Signed-off-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent caa3d55 commit 4ff89ee

File tree

4 files changed

+22
-22
lines changed

4 files changed

+22
-22
lines changed

attr.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ struct pattern {
259259
const char *pattern;
260260
int patternlen;
261261
int nowildcardlen;
262-
unsigned flags; /* EXC_FLAG_* */
262+
unsigned flags; /* PATTERN_FLAG_* */
263263
};
264264

265265
/*
@@ -404,7 +404,7 @@ static struct match_attr *parse_attr_line(const char *line, const char *src,
404404
&res->u.pat.patternlen,
405405
&res->u.pat.flags,
406406
&res->u.pat.nowildcardlen);
407-
if (res->u.pat.flags & EXC_FLAG_NEGATIVE) {
407+
if (res->u.pat.flags & PATTERN_FLAG_NEGATIVE) {
408408
warning(_("Negative patterns are ignored in git attributes\n"
409409
"Use '\\!' for literal leading exclamation."));
410410
goto fail_return;
@@ -991,10 +991,10 @@ static int path_matches(const char *pathname, int pathlen,
991991
int prefix = pat->nowildcardlen;
992992
int isdir = (pathlen && pathname[pathlen - 1] == '/');
993993

994-
if ((pat->flags & EXC_FLAG_MUSTBEDIR) && !isdir)
994+
if ((pat->flags & PATTERN_FLAG_MUSTBEDIR) && !isdir)
995995
return 0;
996996

997-
if (pat->flags & EXC_FLAG_NODIR) {
997+
if (pat->flags & PATTERN_FLAG_NODIR) {
998998
return match_basename(pathname + basename_offset,
999999
pathlen - basename_offset - isdir,
10001000
pattern, prefix,

builtin/check-ignore.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ static const struct option check_ignore_options[] = {
3434

3535
static void output_pattern(const char *path, struct path_pattern *pattern)
3636
{
37-
char *bang = (pattern && pattern->flags & EXC_FLAG_NEGATIVE) ? "!" : "";
38-
char *slash = (pattern && pattern->flags & EXC_FLAG_MUSTBEDIR) ? "/" : "";
37+
char *bang = (pattern && pattern->flags & PATTERN_FLAG_NEGATIVE) ? "!" : "";
38+
char *slash = (pattern && pattern->flags & PATTERN_FLAG_MUSTBEDIR) ? "/" : "";
3939
if (!nul_term_line) {
4040
if (!verbose) {
4141
write_name_quoted(path, stdout, '\n');

dir.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -571,20 +571,20 @@ void parse_exclude_pattern(const char **pattern,
571571

572572
*flags = 0;
573573
if (*p == '!') {
574-
*flags |= EXC_FLAG_NEGATIVE;
574+
*flags |= PATTERN_FLAG_NEGATIVE;
575575
p++;
576576
}
577577
len = strlen(p);
578578
if (len && p[len - 1] == '/') {
579579
len--;
580-
*flags |= EXC_FLAG_MUSTBEDIR;
580+
*flags |= PATTERN_FLAG_MUSTBEDIR;
581581
}
582582
for (i = 0; i < len; i++) {
583583
if (p[i] == '/')
584584
break;
585585
}
586586
if (i == len)
587-
*flags |= EXC_FLAG_NODIR;
587+
*flags |= PATTERN_FLAG_NODIR;
588588
*nowildcardlen = simple_length(p);
589589
/*
590590
* we should have excluded the trailing slash from 'p' too,
@@ -594,7 +594,7 @@ void parse_exclude_pattern(const char **pattern,
594594
if (*nowildcardlen > len)
595595
*nowildcardlen = len;
596596
if (*p == '*' && no_wildcard(p + 1))
597-
*flags |= EXC_FLAG_ENDSWITH;
597+
*flags |= PATTERN_FLAG_ENDSWITH;
598598
*pattern = p;
599599
*patternlen = len;
600600
}
@@ -608,7 +608,7 @@ void add_exclude(const char *string, const char *base,
608608
int nowildcardlen;
609609

610610
parse_exclude_pattern(&string, &patternlen, &flags, &nowildcardlen);
611-
if (flags & EXC_FLAG_MUSTBEDIR) {
611+
if (flags & PATTERN_FLAG_MUSTBEDIR) {
612612
FLEXPTR_ALLOC_MEM(pattern, pattern, string, patternlen);
613613
} else {
614614
pattern = xmalloc(sizeof(*pattern));
@@ -940,7 +940,7 @@ int match_basename(const char *basename, int basenamelen,
940940
if (patternlen == basenamelen &&
941941
!fspathncmp(pattern, basename, basenamelen))
942942
return 1;
943-
} else if (flags & EXC_FLAG_ENDSWITH) {
943+
} else if (flags & PATTERN_FLAG_ENDSWITH) {
944944
/* "*literal" matching against "fooliteral" */
945945
if (patternlen - 1 <= basenamelen &&
946946
!fspathncmp(pattern + 1,
@@ -1039,14 +1039,14 @@ static struct path_pattern *last_exclude_matching_from_list(const char *pathname
10391039
const char *exclude = pattern->pattern;
10401040
int prefix = pattern->nowildcardlen;
10411041

1042-
if (pattern->flags & EXC_FLAG_MUSTBEDIR) {
1042+
if (pattern->flags & PATTERN_FLAG_MUSTBEDIR) {
10431043
if (*dtype == DT_UNKNOWN)
10441044
*dtype = get_dtype(NULL, istate, pathname, pathlen);
10451045
if (*dtype != DT_DIR)
10461046
continue;
10471047
}
10481048

1049-
if (pattern->flags & EXC_FLAG_NODIR) {
1049+
if (pattern->flags & PATTERN_FLAG_NODIR) {
10501050
if (match_basename(basename,
10511051
pathlen - (basename - pathname),
10521052
exclude, prefix, pattern->patternlen,
@@ -1083,7 +1083,7 @@ int is_excluded_from_list(const char *pathname,
10831083
pattern = last_exclude_matching_from_list(pathname, pathlen, basename,
10841084
dtype, pl, istate);
10851085
if (pattern)
1086-
return pattern->flags & EXC_FLAG_NEGATIVE ? 0 : 1;
1086+
return pattern->flags & PATTERN_FLAG_NEGATIVE ? 0 : 1;
10871087
return -1; /* undecided */
10881088
}
10891089

@@ -1198,7 +1198,7 @@ static void prep_exclude(struct dir_struct *dir,
11981198
dir->basebuf.buf + current, &dt);
11991199
dir->basebuf.buf[stk->baselen - 1] = '/';
12001200
if (dir->pattern &&
1201-
dir->pattern->flags & EXC_FLAG_NEGATIVE)
1201+
dir->pattern->flags & PATTERN_FLAG_NEGATIVE)
12021202
dir->pattern = NULL;
12031203
if (dir->pattern) {
12041204
dir->exclude_stack = stk;
@@ -1298,7 +1298,7 @@ int is_excluded(struct dir_struct *dir, struct index_state *istate,
12981298
struct path_pattern *pattern =
12991299
last_exclude_matching(dir, istate, pathname, dtype_p);
13001300
if (pattern)
1301-
return pattern->flags & EXC_FLAG_NEGATIVE ? 0 : 1;
1301+
return pattern->flags & PATTERN_FLAG_NEGATIVE ? 0 : 1;
13021302
return 0;
13031303
}
13041304

dir.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ struct dir_entry {
1111
char name[FLEX_ARRAY]; /* more */
1212
};
1313

14-
#define EXC_FLAG_NODIR 1
15-
#define EXC_FLAG_ENDSWITH 4
16-
#define EXC_FLAG_MUSTBEDIR 8
17-
#define EXC_FLAG_NEGATIVE 16
14+
#define PATTERN_FLAG_NODIR 1
15+
#define PATTERN_FLAG_ENDSWITH 4
16+
#define PATTERN_FLAG_MUSTBEDIR 8
17+
#define PATTERN_FLAG_NEGATIVE 16
1818

1919
struct path_pattern {
2020
/*
@@ -28,7 +28,7 @@ struct path_pattern {
2828
int nowildcardlen;
2929
const char *base;
3030
int baselen;
31-
unsigned flags; /* EXC_FLAG_* */
31+
unsigned flags; /* PATTERN_FLAG_* */
3232

3333
/*
3434
* Counting starts from 1 for line numbers in ignore files,

0 commit comments

Comments
 (0)