|
18 | 18 | #include "ewah/ewok.h"
|
19 | 19 | #include "fsmonitor.h"
|
20 | 20 | #include "submodule-config.h"
|
| 21 | +#include "virtualfilesystem.h" |
21 | 22 |
|
22 | 23 | /*
|
23 | 24 | * Tells read_directory_recursive how a file or directory should be treated.
|
@@ -1402,6 +1403,17 @@ enum pattern_match_result path_matches_pattern_list(
|
1402 | 1403 | int result = NOT_MATCHED;
|
1403 | 1404 | const char *slash_pos;
|
1404 | 1405 |
|
| 1406 | + /* |
| 1407 | + * The virtual file system data is used to prevent git from traversing |
| 1408 | + * any part of the tree that is not in the virtual file system. Return |
| 1409 | + * 1 to exclude the entry if it is not found in the virtual file system, |
| 1410 | + * else fall through to the regular excludes logic as it may further exclude. |
| 1411 | + */ |
| 1412 | + if (*dtype == DT_UNKNOWN) |
| 1413 | + *dtype = resolve_dtype(DT_UNKNOWN, istate, pathname, pathlen); |
| 1414 | + if (is_excluded_from_virtualfilesystem(pathname, pathlen, *dtype) > 0) |
| 1415 | + return 1; |
| 1416 | + |
1405 | 1417 | if (!pl->use_cone_patterns) {
|
1406 | 1418 | pattern = last_matching_pattern_from_list(pathname, pathlen, basename,
|
1407 | 1419 | dtype, pl, istate);
|
@@ -1660,8 +1672,20 @@ struct path_pattern *last_matching_pattern(struct dir_struct *dir,
|
1660 | 1672 | int is_excluded(struct dir_struct *dir, struct index_state *istate,
|
1661 | 1673 | const char *pathname, int *dtype_p)
|
1662 | 1674 | {
|
1663 |
| - struct path_pattern *pattern = |
1664 |
| - last_matching_pattern(dir, istate, pathname, dtype_p); |
| 1675 | + struct path_pattern *pattern; |
| 1676 | + |
| 1677 | + /* |
| 1678 | + * The virtual file system data is used to prevent git from traversing |
| 1679 | + * any part of the tree that is not in the virtual file system. Return |
| 1680 | + * 1 to exclude the entry if it is not found in the virtual file system, |
| 1681 | + * else fall through to the regular excludes logic as it may further exclude. |
| 1682 | + */ |
| 1683 | + if (*dtype_p == DT_UNKNOWN) |
| 1684 | + *dtype_p = resolve_dtype(DT_UNKNOWN, istate, pathname, strlen(pathname)); |
| 1685 | + if (is_excluded_from_virtualfilesystem(pathname, strlen(pathname), *dtype_p) > 0) |
| 1686 | + return 1; |
| 1687 | + |
| 1688 | + pattern = last_matching_pattern(dir, istate, pathname, dtype_p); |
1665 | 1689 | if (pattern)
|
1666 | 1690 | return pattern->flags & PATTERN_FLAG_NEGATIVE ? 0 : 1;
|
1667 | 1691 | return 0;
|
@@ -2211,6 +2235,8 @@ static enum path_treatment treat_path(struct dir_struct *dir,
|
2211 | 2235 | ignore_case);
|
2212 | 2236 | if (dtype != DT_DIR && has_path_in_index)
|
2213 | 2237 | return path_none;
|
| 2238 | + if (is_excluded_from_virtualfilesystem(path->buf, path->len, dtype) > 0) |
| 2239 | + return path_excluded; |
2214 | 2240 |
|
2215 | 2241 | /*
|
2216 | 2242 | * When we are looking at a directory P in the working tree,
|
@@ -2415,6 +2441,8 @@ static void add_path_to_appropriate_result_list(struct dir_struct *dir,
|
2415 | 2441 | /* add the path to the appropriate result list */
|
2416 | 2442 | switch (state) {
|
2417 | 2443 | case path_excluded:
|
| 2444 | + if (is_excluded_from_virtualfilesystem(path->buf, path->len, DT_DIR) > 0) |
| 2445 | + break; |
2418 | 2446 | if (dir->flags & DIR_SHOW_IGNORED)
|
2419 | 2447 | dir_add_name(dir, istate, path->buf, path->len);
|
2420 | 2448 | else if ((dir->flags & DIR_SHOW_IGNORED_TOO) ||
|
|
0 commit comments