Skip to content

Commit 65edd96

Browse files
derrickstoleegitster
authored andcommitted
treewide: rename 'exclude' methods to 'pattern'
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 renames several methods defined in dir.h to make more sense with the renamed 'struct exclude_list' to 'struct pattern_list' and 'struct exclude' to 'struct path_pattern': * last_exclude_matching() -> last_matching_pattern() * parse_exclude() -> parse_path_pattern() In addition, the word 'exclude' was replaced with 'pattern' in the methods below: * add_exclude_list() * add_excludes_from_file_to_list() * add_excludes_from_file() * add_excludes_from_blob_to_list() * add_exclude() * clear_exclude_list() A few methods with the word "exclude" remain. These will be handled seperately. In particular, the method "is_excluded()" is concretely about the .gitignore file relative to a specific directory. This is the important boundary between library and consumer: is_excluded() cares about .gitignore, but is_excluded() calls last_matching_pattern() to make that decision. Signed-off-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4ff89ee commit 65edd96

File tree

11 files changed

+67
-67
lines changed

11 files changed

+67
-67
lines changed

Documentation/RelNotes/2.7.1.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Fixes since v2.7
1010
setting GIT_WORK_TREE environment themselves.
1111

1212
* The "exclude_list" structure has the usual "alloc, nr" pair of
13-
fields to be used by ALLOC_GROW(), but clear_exclude_list() forgot
13+
fields to be used by ALLOC_GROW(), but clear_pattern_list() forgot
1414
to reset 'alloc' to 0 when it cleared 'nr' to discard the managed
1515
array.
1616

Documentation/RelNotes/2.8.0.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ notes for details).
270270
setting GIT_WORK_TREE environment themselves.
271271

272272
* The "exclude_list" structure has the usual "alloc, nr" pair of
273-
fields to be used by ALLOC_GROW(), but clear_exclude_list() forgot
273+
fields to be used by ALLOC_GROW(), but clear_pattern_list() forgot
274274
to reset 'alloc' to 0 when it cleared 'nr' to discard the managed
275275
array.
276276

Documentation/technical/api-directory-listing.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,11 @@ marked. If you to exclude files, make sure you have loaded index first.
111111
* Prepare `struct dir_struct dir` and clear it with `memset(&dir, 0,
112112
sizeof(dir))`.
113113

114-
* To add single exclude pattern, call `add_exclude_list()` and then
115-
`add_exclude()`.
114+
* To add single exclude pattern, call `add_pattern_list()` and then
115+
`add_pattern()`.
116116

117117
* To add patterns from a file (e.g. `.git/info/exclude`), call
118-
`add_excludes_from_file()` , and/or set `dir.exclude_per_dir`. A
118+
`add_patterns_from_file()` , and/or set `dir.exclude_per_dir`. A
119119
short-hand function `setup_standard_excludes()` can be used to set
120120
up the standard set of exclude settings.
121121

attr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ static struct match_attr *parse_attr_line(const char *line, const char *src,
400400
char *p = (char *)&(res->state[num_attr]);
401401
memcpy(p, name, namelen);
402402
res->u.pat.pattern = p;
403-
parse_exclude_pattern(&res->u.pat.pattern,
403+
parse_path_pattern(&res->u.pat.pattern,
404404
&res->u.pat.patternlen,
405405
&res->u.pat.flags,
406406
&res->u.pat.nowildcardlen);

builtin/check-ignore.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ static int check_ignore(struct dir_struct *dir,
106106
pattern = NULL;
107107
if (!seen[i]) {
108108
int dtype = DT_UNKNOWN;
109-
pattern = last_exclude_matching(dir, &the_index,
109+
pattern = last_matching_pattern(dir, &the_index,
110110
full_path, &dtype);
111111
}
112112
if (!quiet && (pattern || show_non_matching))

builtin/clean.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -670,15 +670,15 @@ static int filter_by_patterns_cmd(void)
670670
break;
671671

672672
memset(&dir, 0, sizeof(dir));
673-
pl = add_exclude_list(&dir, EXC_CMDL, "manual exclude");
673+
pl = add_pattern_list(&dir, EXC_CMDL, "manual exclude");
674674
ignore_list = strbuf_split_max(&confirm, ' ', 0);
675675

676676
for (i = 0; ignore_list[i]; i++) {
677677
strbuf_trim(ignore_list[i]);
678678
if (!ignore_list[i]->len)
679679
continue;
680680

681-
add_exclude(ignore_list[i]->buf, "", 0, pl, -(i+1));
681+
add_pattern(ignore_list[i]->buf, "", 0, pl, -(i+1));
682682
}
683683

684684
changed = 0;
@@ -957,9 +957,9 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
957957
if (!ignored)
958958
setup_standard_excludes(&dir);
959959

960-
pl = add_exclude_list(&dir, EXC_CMDL, "--exclude option");
960+
pl = add_pattern_list(&dir, EXC_CMDL, "--exclude option");
961961
for (i = 0; i < exclude_list.nr; i++)
962-
add_exclude(exclude_list.items[i].string, "", 0, pl, -(i+1));
962+
add_pattern(exclude_list.items[i].string, "", 0, pl, -(i+1));
963963

964964
parse_pathspec(&pathspec, 0,
965965
PATHSPEC_PREFER_CWD,

builtin/ls-files.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ static int option_parse_exclude_from(const struct option *opt,
492492
BUG_ON_OPT_NEG(unset);
493493

494494
exc_given = 1;
495-
add_excludes_from_file(dir, arg);
495+
add_patterns_from_file(dir, arg);
496496

497497
return 0;
498498
}
@@ -594,9 +594,9 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix)
594594

595595
argc = parse_options(argc, argv, prefix, builtin_ls_files_options,
596596
ls_files_usage, 0);
597-
pl = add_exclude_list(&dir, EXC_CMDL, "--exclude option");
597+
pl = add_pattern_list(&dir, EXC_CMDL, "--exclude option");
598598
for (i = 0; i < exclude_list.nr; i++) {
599-
add_exclude(exclude_list.items[i].string, "", 0, pl, --exclude_args);
599+
add_pattern(exclude_list.items[i].string, "", 0, pl, --exclude_args);
600600
}
601601
if (show_tag || show_valid_bit || show_fsmonitor_bit) {
602602
tag_cached = "H ";

0 commit comments

Comments
 (0)