|
11 | 11 |
|
12 | 12 | #include "git-compat-util.h" |
13 | 13 | #include "abspath.h" |
| 14 | +#include "virtualfilesystem.h" |
14 | 15 | #include "config.h" |
15 | 16 | #include "convert.h" |
16 | 17 | #include "dir.h" |
@@ -1480,6 +1481,19 @@ enum pattern_match_result path_matches_pattern_list( |
1480 | 1481 | int result = NOT_MATCHED; |
1481 | 1482 | size_t slash_pos; |
1482 | 1483 |
|
| 1484 | + if (core_virtualfilesystem) { |
| 1485 | + /* |
| 1486 | + * The virtual file system data is used to prevent git from traversing |
| 1487 | + * any part of the tree that is not in the virtual file system. Return |
| 1488 | + * 1 to exclude the entry if it is not found in the virtual file system, |
| 1489 | + * else fall through to the regular excludes logic as it may further exclude. |
| 1490 | + */ |
| 1491 | + if (*dtype == DT_UNKNOWN) |
| 1492 | + *dtype = resolve_dtype(DT_UNKNOWN, istate, pathname, pathlen); |
| 1493 | + if (is_excluded_from_virtualfilesystem(pathname, pathlen, *dtype) > 0) |
| 1494 | + return 1; |
| 1495 | + } |
| 1496 | + |
1483 | 1497 | if (!pl->use_cone_patterns) { |
1484 | 1498 | pattern = last_matching_pattern_from_list(pathname, pathlen, basename, |
1485 | 1499 | dtype, pl, istate); |
@@ -1824,8 +1838,22 @@ struct path_pattern *last_matching_pattern(struct dir_struct *dir, |
1824 | 1838 | int is_excluded(struct dir_struct *dir, struct index_state *istate, |
1825 | 1839 | const char *pathname, int *dtype_p) |
1826 | 1840 | { |
1827 | | - struct path_pattern *pattern = |
1828 | | - last_matching_pattern(dir, istate, pathname, dtype_p); |
| 1841 | + struct path_pattern *pattern; |
| 1842 | + |
| 1843 | + if (core_virtualfilesystem) { |
| 1844 | + /* |
| 1845 | + * The virtual file system data is used to prevent git from traversing |
| 1846 | + * any part of the tree that is not in the virtual file system. Return |
| 1847 | + * 1 to exclude the entry if it is not found in the virtual file system, |
| 1848 | + * else fall through to the regular excludes logic as it may further exclude. |
| 1849 | + */ |
| 1850 | + if (*dtype_p == DT_UNKNOWN) |
| 1851 | + *dtype_p = resolve_dtype(DT_UNKNOWN, istate, pathname, strlen(pathname)); |
| 1852 | + if (is_excluded_from_virtualfilesystem(pathname, strlen(pathname), *dtype_p) > 0) |
| 1853 | + return 1; |
| 1854 | + } |
| 1855 | + |
| 1856 | + pattern = last_matching_pattern(dir, istate, pathname, dtype_p); |
1829 | 1857 | if (pattern) |
1830 | 1858 | return pattern->flags & PATTERN_FLAG_NEGATIVE ? 0 : 1; |
1831 | 1859 | return 0; |
@@ -2443,6 +2471,8 @@ static enum path_treatment treat_path(struct dir_struct *dir, |
2443 | 2471 | ignore_case); |
2444 | 2472 | if (dtype != DT_DIR && has_path_in_index) |
2445 | 2473 | return path_none; |
| 2474 | + if (is_excluded_from_virtualfilesystem(path->buf, path->len, dtype) > 0) |
| 2475 | + return path_excluded; |
2446 | 2476 |
|
2447 | 2477 | /* |
2448 | 2478 | * When we are looking at a directory P in the working tree, |
@@ -2647,6 +2677,8 @@ static void add_path_to_appropriate_result_list(struct dir_struct *dir, |
2647 | 2677 | /* add the path to the appropriate result list */ |
2648 | 2678 | switch (state) { |
2649 | 2679 | case path_excluded: |
| 2680 | + if (is_excluded_from_virtualfilesystem(path->buf, path->len, DT_DIR) > 0) |
| 2681 | + break; |
2650 | 2682 | if (dir->flags & DIR_SHOW_IGNORED) |
2651 | 2683 | dir_add_name(dir, istate, path->buf, path->len); |
2652 | 2684 | else if ((dir->flags & DIR_SHOW_IGNORED_TOO) || |
|
0 commit comments