|
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"
|
@@ -1478,6 +1479,19 @@ enum pattern_match_result path_matches_pattern_list(
|
1478 | 1479 | int result = NOT_MATCHED;
|
1479 | 1480 | size_t slash_pos;
|
1480 | 1481 |
|
| 1482 | + if (core_virtualfilesystem) { |
| 1483 | + /* |
| 1484 | + * The virtual file system data is used to prevent git from traversing |
| 1485 | + * any part of the tree that is not in the virtual file system. Return |
| 1486 | + * 1 to exclude the entry if it is not found in the virtual file system, |
| 1487 | + * else fall through to the regular excludes logic as it may further exclude. |
| 1488 | + */ |
| 1489 | + if (*dtype == DT_UNKNOWN) |
| 1490 | + *dtype = resolve_dtype(DT_UNKNOWN, istate, pathname, pathlen); |
| 1491 | + if (is_excluded_from_virtualfilesystem(pathname, pathlen, *dtype) > 0) |
| 1492 | + return 1; |
| 1493 | + } |
| 1494 | + |
1481 | 1495 | if (!pl->use_cone_patterns) {
|
1482 | 1496 | pattern = last_matching_pattern_from_list(pathname, pathlen, basename,
|
1483 | 1497 | dtype, pl, istate);
|
@@ -1822,8 +1836,22 @@ struct path_pattern *last_matching_pattern(struct dir_struct *dir,
|
1822 | 1836 | int is_excluded(struct dir_struct *dir, struct index_state *istate,
|
1823 | 1837 | const char *pathname, int *dtype_p)
|
1824 | 1838 | {
|
1825 |
| - struct path_pattern *pattern = |
1826 |
| - last_matching_pattern(dir, istate, pathname, dtype_p); |
| 1839 | + struct path_pattern *pattern; |
| 1840 | + |
| 1841 | + if (core_virtualfilesystem) { |
| 1842 | + /* |
| 1843 | + * The virtual file system data is used to prevent git from traversing |
| 1844 | + * any part of the tree that is not in the virtual file system. Return |
| 1845 | + * 1 to exclude the entry if it is not found in the virtual file system, |
| 1846 | + * else fall through to the regular excludes logic as it may further exclude. |
| 1847 | + */ |
| 1848 | + if (*dtype_p == DT_UNKNOWN) |
| 1849 | + *dtype_p = resolve_dtype(DT_UNKNOWN, istate, pathname, strlen(pathname)); |
| 1850 | + if (is_excluded_from_virtualfilesystem(pathname, strlen(pathname), *dtype_p) > 0) |
| 1851 | + return 1; |
| 1852 | + } |
| 1853 | + |
| 1854 | + pattern = last_matching_pattern(dir, istate, pathname, dtype_p); |
1827 | 1855 | if (pattern)
|
1828 | 1856 | return pattern->flags & PATTERN_FLAG_NEGATIVE ? 0 : 1;
|
1829 | 1857 | 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