|
6 | 6 | * Junio Hamano, 2005-2006 |
7 | 7 | */ |
8 | 8 | #include "cache.h" |
| 9 | +#include "virtualfilesystem.h" |
9 | 10 | #include "config.h" |
10 | 11 | #include "dir.h" |
11 | 12 | #include "object-store.h" |
@@ -1418,6 +1419,17 @@ enum pattern_match_result path_matches_pattern_list( |
1418 | 1419 | int result = NOT_MATCHED; |
1419 | 1420 | size_t slash_pos; |
1420 | 1421 |
|
| 1422 | + /* |
| 1423 | + * The virtual file system data is used to prevent git from traversing |
| 1424 | + * any part of the tree that is not in the virtual file system. Return |
| 1425 | + * 1 to exclude the entry if it is not found in the virtual file system, |
| 1426 | + * else fall through to the regular excludes logic as it may further exclude. |
| 1427 | + */ |
| 1428 | + if (*dtype == DT_UNKNOWN) |
| 1429 | + *dtype = resolve_dtype(DT_UNKNOWN, istate, pathname, pathlen); |
| 1430 | + if (is_excluded_from_virtualfilesystem(pathname, pathlen, *dtype) > 0) |
| 1431 | + return 1; |
| 1432 | + |
1421 | 1433 | if (!pl->use_cone_patterns) { |
1422 | 1434 | pattern = last_matching_pattern_from_list(pathname, pathlen, basename, |
1423 | 1435 | dtype, pl, istate); |
@@ -1760,8 +1772,20 @@ struct path_pattern *last_matching_pattern(struct dir_struct *dir, |
1760 | 1772 | int is_excluded(struct dir_struct *dir, struct index_state *istate, |
1761 | 1773 | const char *pathname, int *dtype_p) |
1762 | 1774 | { |
1763 | | - struct path_pattern *pattern = |
1764 | | - last_matching_pattern(dir, istate, pathname, dtype_p); |
| 1775 | + struct path_pattern *pattern; |
| 1776 | + |
| 1777 | + /* |
| 1778 | + * The virtual file system data is used to prevent git from traversing |
| 1779 | + * any part of the tree that is not in the virtual file system. Return |
| 1780 | + * 1 to exclude the entry if it is not found in the virtual file system, |
| 1781 | + * else fall through to the regular excludes logic as it may further exclude. |
| 1782 | + */ |
| 1783 | + if (*dtype_p == DT_UNKNOWN) |
| 1784 | + *dtype_p = resolve_dtype(DT_UNKNOWN, istate, pathname, strlen(pathname)); |
| 1785 | + if (is_excluded_from_virtualfilesystem(pathname, strlen(pathname), *dtype_p) > 0) |
| 1786 | + return 1; |
| 1787 | + |
| 1788 | + pattern = last_matching_pattern(dir, istate, pathname, dtype_p); |
1765 | 1789 | if (pattern) |
1766 | 1790 | return pattern->flags & PATTERN_FLAG_NEGATIVE ? 0 : 1; |
1767 | 1791 | return 0; |
@@ -2326,6 +2350,8 @@ static enum path_treatment treat_path(struct dir_struct *dir, |
2326 | 2350 | ignore_case); |
2327 | 2351 | if (dtype != DT_DIR && has_path_in_index) |
2328 | 2352 | return path_none; |
| 2353 | + if (is_excluded_from_virtualfilesystem(path->buf, path->len, dtype) > 0) |
| 2354 | + return path_excluded; |
2329 | 2355 |
|
2330 | 2356 | /* |
2331 | 2357 | * When we are looking at a directory P in the working tree, |
@@ -2530,6 +2556,8 @@ static void add_path_to_appropriate_result_list(struct dir_struct *dir, |
2530 | 2556 | /* add the path to the appropriate result list */ |
2531 | 2557 | switch (state) { |
2532 | 2558 | case path_excluded: |
| 2559 | + if (is_excluded_from_virtualfilesystem(path->buf, path->len, DT_DIR) > 0) |
| 2560 | + break; |
2533 | 2561 | if (dir->flags & DIR_SHOW_IGNORED) |
2534 | 2562 | dir_add_name(dir, istate, path->buf, path->len); |
2535 | 2563 | else if ((dir->flags & DIR_SHOW_IGNORED_TOO) || |
|
0 commit comments