|
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" |
@@ -1498,6 +1499,19 @@ enum pattern_match_result path_matches_pattern_list( |
1498 | 1499 | int result = NOT_MATCHED; |
1499 | 1500 | size_t slash_pos; |
1500 | 1501 |
|
| 1502 | + if (core_virtualfilesystem) { |
| 1503 | + /* |
| 1504 | + * The virtual file system data is used to prevent git from traversing |
| 1505 | + * any part of the tree that is not in the virtual file system. Return |
| 1506 | + * 1 to exclude the entry if it is not found in the virtual file system, |
| 1507 | + * else fall through to the regular excludes logic as it may further exclude. |
| 1508 | + */ |
| 1509 | + if (*dtype == DT_UNKNOWN) |
| 1510 | + *dtype = resolve_dtype(DT_UNKNOWN, istate, pathname, pathlen); |
| 1511 | + if (is_excluded_from_virtualfilesystem(pathname, pathlen, *dtype) > 0) |
| 1512 | + return 1; |
| 1513 | + } |
| 1514 | + |
1501 | 1515 | if (!pl->use_cone_patterns) { |
1502 | 1516 | pattern = last_matching_pattern_from_list(pathname, pathlen, basename, |
1503 | 1517 | dtype, pl, istate); |
@@ -1842,8 +1856,22 @@ struct path_pattern *last_matching_pattern(struct dir_struct *dir, |
1842 | 1856 | int is_excluded(struct dir_struct *dir, struct index_state *istate, |
1843 | 1857 | const char *pathname, int *dtype_p) |
1844 | 1858 | { |
1845 | | - struct path_pattern *pattern = |
1846 | | - last_matching_pattern(dir, istate, pathname, dtype_p); |
| 1859 | + struct path_pattern *pattern; |
| 1860 | + |
| 1861 | + if (core_virtualfilesystem) { |
| 1862 | + /* |
| 1863 | + * The virtual file system data is used to prevent git from traversing |
| 1864 | + * any part of the tree that is not in the virtual file system. Return |
| 1865 | + * 1 to exclude the entry if it is not found in the virtual file system, |
| 1866 | + * else fall through to the regular excludes logic as it may further exclude. |
| 1867 | + */ |
| 1868 | + if (*dtype_p == DT_UNKNOWN) |
| 1869 | + *dtype_p = resolve_dtype(DT_UNKNOWN, istate, pathname, strlen(pathname)); |
| 1870 | + if (is_excluded_from_virtualfilesystem(pathname, strlen(pathname), *dtype_p) > 0) |
| 1871 | + return 1; |
| 1872 | + } |
| 1873 | + |
| 1874 | + pattern = last_matching_pattern(dir, istate, pathname, dtype_p); |
1847 | 1875 | if (pattern) |
1848 | 1876 | return pattern->flags & PATTERN_FLAG_NEGATIVE ? 0 : 1; |
1849 | 1877 | return 0; |
@@ -2461,6 +2489,8 @@ static enum path_treatment treat_path(struct dir_struct *dir, |
2461 | 2489 | ignore_case); |
2462 | 2490 | if (dtype != DT_DIR && has_path_in_index) |
2463 | 2491 | return path_none; |
| 2492 | + if (is_excluded_from_virtualfilesystem(path->buf, path->len, dtype) > 0) |
| 2493 | + return path_excluded; |
2464 | 2494 |
|
2465 | 2495 | /* |
2466 | 2496 | * When we are looking at a directory P in the working tree, |
@@ -2665,6 +2695,8 @@ static void add_path_to_appropriate_result_list(struct dir_struct *dir, |
2665 | 2695 | /* add the path to the appropriate result list */ |
2666 | 2696 | switch (state) { |
2667 | 2697 | case path_excluded: |
| 2698 | + if (is_excluded_from_virtualfilesystem(path->buf, path->len, DT_DIR) > 0) |
| 2699 | + break; |
2668 | 2700 | if (dir->flags & DIR_SHOW_IGNORED) |
2669 | 2701 | dir_add_name(dir, istate, path->buf, path->len); |
2670 | 2702 | else if ((dir->flags & DIR_SHOW_IGNORED_TOO) || |
|
0 commit comments