|
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" |
@@ -1485,6 +1486,19 @@ enum pattern_match_result path_matches_pattern_list( |
1485 | 1486 | int result = NOT_MATCHED; |
1486 | 1487 | size_t slash_pos; |
1487 | 1488 |
|
| 1489 | + if (core_virtualfilesystem) { |
| 1490 | + /* |
| 1491 | + * The virtual file system data is used to prevent git from traversing |
| 1492 | + * any part of the tree that is not in the virtual file system. Return |
| 1493 | + * 1 to exclude the entry if it is not found in the virtual file system, |
| 1494 | + * else fall through to the regular excludes logic as it may further exclude. |
| 1495 | + */ |
| 1496 | + if (*dtype == DT_UNKNOWN) |
| 1497 | + *dtype = resolve_dtype(DT_UNKNOWN, istate, pathname, pathlen); |
| 1498 | + if (is_excluded_from_virtualfilesystem(pathname, pathlen, *dtype) > 0) |
| 1499 | + return 1; |
| 1500 | + } |
| 1501 | + |
1488 | 1502 | if (!pl->use_cone_patterns) { |
1489 | 1503 | pattern = last_matching_pattern_from_list(pathname, pathlen, basename, |
1490 | 1504 | dtype, pl, istate); |
@@ -1829,8 +1843,22 @@ struct path_pattern *last_matching_pattern(struct dir_struct *dir, |
1829 | 1843 | int is_excluded(struct dir_struct *dir, struct index_state *istate, |
1830 | 1844 | const char *pathname, int *dtype_p) |
1831 | 1845 | { |
1832 | | - struct path_pattern *pattern = |
1833 | | - last_matching_pattern(dir, istate, pathname, dtype_p); |
| 1846 | + struct path_pattern *pattern; |
| 1847 | + |
| 1848 | + if (core_virtualfilesystem) { |
| 1849 | + /* |
| 1850 | + * The virtual file system data is used to prevent git from traversing |
| 1851 | + * any part of the tree that is not in the virtual file system. Return |
| 1852 | + * 1 to exclude the entry if it is not found in the virtual file system, |
| 1853 | + * else fall through to the regular excludes logic as it may further exclude. |
| 1854 | + */ |
| 1855 | + if (*dtype_p == DT_UNKNOWN) |
| 1856 | + *dtype_p = resolve_dtype(DT_UNKNOWN, istate, pathname, strlen(pathname)); |
| 1857 | + if (is_excluded_from_virtualfilesystem(pathname, strlen(pathname), *dtype_p) > 0) |
| 1858 | + return 1; |
| 1859 | + } |
| 1860 | + |
| 1861 | + pattern = last_matching_pattern(dir, istate, pathname, dtype_p); |
1834 | 1862 | if (pattern) |
1835 | 1863 | return pattern->flags & PATTERN_FLAG_NEGATIVE ? 0 : 1; |
1836 | 1864 | return 0; |
@@ -2448,6 +2476,8 @@ static enum path_treatment treat_path(struct dir_struct *dir, |
2448 | 2476 | ignore_case); |
2449 | 2477 | if (dtype != DT_DIR && has_path_in_index) |
2450 | 2478 | return path_none; |
| 2479 | + if (is_excluded_from_virtualfilesystem(path->buf, path->len, dtype) > 0) |
| 2480 | + return path_excluded; |
2451 | 2481 |
|
2452 | 2482 | /* |
2453 | 2483 | * When we are looking at a directory P in the working tree, |
@@ -2652,6 +2682,8 @@ static void add_path_to_appropriate_result_list(struct dir_struct *dir, |
2652 | 2682 | /* add the path to the appropriate result list */ |
2653 | 2683 | switch (state) { |
2654 | 2684 | case path_excluded: |
| 2685 | + if (is_excluded_from_virtualfilesystem(path->buf, path->len, DT_DIR) > 0) |
| 2686 | + break; |
2655 | 2687 | if (dir->flags & DIR_SHOW_IGNORED) |
2656 | 2688 | dir_add_name(dir, istate, path->buf, path->len); |
2657 | 2689 | else if ((dir->flags & DIR_SHOW_IGNORED_TOO) || |
|
0 commit comments