|
10 | 10 |
|
11 | 11 | #include "git-compat-util.h" |
12 | 12 | #include "abspath.h" |
| 13 | +#include "virtualfilesystem.h" |
13 | 14 | #include "config.h" |
14 | 15 | #include "convert.h" |
15 | 16 | #include "dir.h" |
@@ -1475,6 +1476,19 @@ enum pattern_match_result path_matches_pattern_list( |
1475 | 1476 | int result = NOT_MATCHED; |
1476 | 1477 | size_t slash_pos; |
1477 | 1478 |
|
| 1479 | + if (core_virtualfilesystem) { |
| 1480 | + /* |
| 1481 | + * The virtual file system data is used to prevent git from traversing |
| 1482 | + * any part of the tree that is not in the virtual file system. Return |
| 1483 | + * 1 to exclude the entry if it is not found in the virtual file system, |
| 1484 | + * else fall through to the regular excludes logic as it may further exclude. |
| 1485 | + */ |
| 1486 | + if (*dtype == DT_UNKNOWN) |
| 1487 | + *dtype = resolve_dtype(DT_UNKNOWN, istate, pathname, pathlen); |
| 1488 | + if (is_excluded_from_virtualfilesystem(pathname, pathlen, *dtype) > 0) |
| 1489 | + return 1; |
| 1490 | + } |
| 1491 | + |
1478 | 1492 | if (!pl->use_cone_patterns) { |
1479 | 1493 | pattern = last_matching_pattern_from_list(pathname, pathlen, basename, |
1480 | 1494 | dtype, pl, istate); |
@@ -1819,8 +1833,22 @@ struct path_pattern *last_matching_pattern(struct dir_struct *dir, |
1819 | 1833 | int is_excluded(struct dir_struct *dir, struct index_state *istate, |
1820 | 1834 | const char *pathname, int *dtype_p) |
1821 | 1835 | { |
1822 | | - struct path_pattern *pattern = |
1823 | | - last_matching_pattern(dir, istate, pathname, dtype_p); |
| 1836 | + struct path_pattern *pattern; |
| 1837 | + |
| 1838 | + if (core_virtualfilesystem) { |
| 1839 | + /* |
| 1840 | + * The virtual file system data is used to prevent git from traversing |
| 1841 | + * any part of the tree that is not in the virtual file system. Return |
| 1842 | + * 1 to exclude the entry if it is not found in the virtual file system, |
| 1843 | + * else fall through to the regular excludes logic as it may further exclude. |
| 1844 | + */ |
| 1845 | + if (*dtype_p == DT_UNKNOWN) |
| 1846 | + *dtype_p = resolve_dtype(DT_UNKNOWN, istate, pathname, strlen(pathname)); |
| 1847 | + if (is_excluded_from_virtualfilesystem(pathname, strlen(pathname), *dtype_p) > 0) |
| 1848 | + return 1; |
| 1849 | + } |
| 1850 | + |
| 1851 | + pattern = last_matching_pattern(dir, istate, pathname, dtype_p); |
1824 | 1852 | if (pattern) |
1825 | 1853 | return pattern->flags & PATTERN_FLAG_NEGATIVE ? 0 : 1; |
1826 | 1854 | return 0; |
@@ -2438,6 +2466,8 @@ static enum path_treatment treat_path(struct dir_struct *dir, |
2438 | 2466 | ignore_case); |
2439 | 2467 | if (dtype != DT_DIR && has_path_in_index) |
2440 | 2468 | return path_none; |
| 2469 | + if (is_excluded_from_virtualfilesystem(path->buf, path->len, dtype) > 0) |
| 2470 | + return path_excluded; |
2441 | 2471 |
|
2442 | 2472 | /* |
2443 | 2473 | * When we are looking at a directory P in the working tree, |
@@ -2642,6 +2672,8 @@ static void add_path_to_appropriate_result_list(struct dir_struct *dir, |
2642 | 2672 | /* add the path to the appropriate result list */ |
2643 | 2673 | switch (state) { |
2644 | 2674 | case path_excluded: |
| 2675 | + if (is_excluded_from_virtualfilesystem(path->buf, path->len, DT_DIR) > 0) |
| 2676 | + break; |
2645 | 2677 | if (dir->flags & DIR_SHOW_IGNORED) |
2646 | 2678 | dir_add_name(dir, istate, path->buf, path->len); |
2647 | 2679 | else if ((dir->flags & DIR_SHOW_IGNORED_TOO) || |
|
0 commit comments