|
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. |
@@ -1395,6 +1396,17 @@ enum pattern_match_result path_matches_pattern_list( |
1395 | 1396 | int result = NOT_MATCHED; |
1396 | 1397 | const char *slash_pos; |
1397 | 1398 |
|
| 1399 | + /* |
| 1400 | + * The virtual file system data is used to prevent git from traversing |
| 1401 | + * any part of the tree that is not in the virtual file system. Return |
| 1402 | + * 1 to exclude the entry if it is not found in the virtual file system, |
| 1403 | + * else fall through to the regular excludes logic as it may further exclude. |
| 1404 | + */ |
| 1405 | + if (*dtype == DT_UNKNOWN) |
| 1406 | + *dtype = resolve_dtype(DT_UNKNOWN, istate, pathname, pathlen); |
| 1407 | + if (is_excluded_from_virtualfilesystem(pathname, pathlen, *dtype) > 0) |
| 1408 | + return 1; |
| 1409 | + |
1398 | 1410 | if (!pl->use_cone_patterns) { |
1399 | 1411 | pattern = last_matching_pattern_from_list(pathname, pathlen, basename, |
1400 | 1412 | dtype, pl, istate); |
@@ -1653,8 +1665,20 @@ struct path_pattern *last_matching_pattern(struct dir_struct *dir, |
1653 | 1665 | int is_excluded(struct dir_struct *dir, struct index_state *istate, |
1654 | 1666 | const char *pathname, int *dtype_p) |
1655 | 1667 | { |
1656 | | - struct path_pattern *pattern = |
1657 | | - last_matching_pattern(dir, istate, pathname, dtype_p); |
| 1668 | + struct path_pattern *pattern; |
| 1669 | + |
| 1670 | + /* |
| 1671 | + * The virtual file system data is used to prevent git from traversing |
| 1672 | + * any part of the tree that is not in the virtual file system. Return |
| 1673 | + * 1 to exclude the entry if it is not found in the virtual file system, |
| 1674 | + * else fall through to the regular excludes logic as it may further exclude. |
| 1675 | + */ |
| 1676 | + if (*dtype_p == DT_UNKNOWN) |
| 1677 | + *dtype_p = resolve_dtype(DT_UNKNOWN, istate, pathname, strlen(pathname)); |
| 1678 | + if (is_excluded_from_virtualfilesystem(pathname, strlen(pathname), *dtype_p) > 0) |
| 1679 | + return 1; |
| 1680 | + |
| 1681 | + pattern = last_matching_pattern(dir, istate, pathname, dtype_p); |
1658 | 1682 | if (pattern) |
1659 | 1683 | return pattern->flags & PATTERN_FLAG_NEGATIVE ? 0 : 1; |
1660 | 1684 | return 0; |
@@ -2202,6 +2226,8 @@ static enum path_treatment treat_path(struct dir_struct *dir, |
2202 | 2226 | ignore_case); |
2203 | 2227 | if (dtype != DT_DIR && has_path_in_index) |
2204 | 2228 | return path_none; |
| 2229 | + if (is_excluded_from_virtualfilesystem(path->buf, path->len, dtype) > 0) |
| 2230 | + return path_excluded; |
2205 | 2231 |
|
2206 | 2232 | /* |
2207 | 2233 | * When we are looking at a directory P in the working tree, |
@@ -2406,6 +2432,8 @@ static void add_path_to_appropriate_result_list(struct dir_struct *dir, |
2406 | 2432 | /* add the path to the appropriate result list */ |
2407 | 2433 | switch (state) { |
2408 | 2434 | case path_excluded: |
| 2435 | + if (is_excluded_from_virtualfilesystem(path->buf, path->len, DT_DIR) > 0) |
| 2436 | + break; |
2409 | 2437 | if (dir->flags & DIR_SHOW_IGNORED) |
2410 | 2438 | dir_add_name(dir, istate, path->buf, path->len); |
2411 | 2439 | else if ((dir->flags & DIR_SHOW_IGNORED_TOO) || |
|
0 commit comments