|
7 | 7 | */ |
8 | 8 | #include "git-compat-util.h" |
9 | 9 | #include "abspath.h" |
| 10 | +#include "virtualfilesystem.h" |
10 | 11 | #include "config.h" |
11 | 12 | #include "convert.h" |
12 | 13 | #include "dir.h" |
@@ -1443,6 +1444,19 @@ enum pattern_match_result path_matches_pattern_list( |
1443 | 1444 | int result = NOT_MATCHED; |
1444 | 1445 | size_t slash_pos; |
1445 | 1446 |
|
| 1447 | + if (core_virtualfilesystem) { |
| 1448 | + /* |
| 1449 | + * The virtual file system data is used to prevent git from traversing |
| 1450 | + * any part of the tree that is not in the virtual file system. Return |
| 1451 | + * 1 to exclude the entry if it is not found in the virtual file system, |
| 1452 | + * else fall through to the regular excludes logic as it may further exclude. |
| 1453 | + */ |
| 1454 | + if (*dtype == DT_UNKNOWN) |
| 1455 | + *dtype = resolve_dtype(DT_UNKNOWN, istate, pathname, pathlen); |
| 1456 | + if (is_excluded_from_virtualfilesystem(pathname, pathlen, *dtype) > 0) |
| 1457 | + return 1; |
| 1458 | + } |
| 1459 | + |
1446 | 1460 | if (!pl->use_cone_patterns) { |
1447 | 1461 | pattern = last_matching_pattern_from_list(pathname, pathlen, basename, |
1448 | 1462 | dtype, pl, istate); |
@@ -1787,8 +1801,22 @@ struct path_pattern *last_matching_pattern(struct dir_struct *dir, |
1787 | 1801 | int is_excluded(struct dir_struct *dir, struct index_state *istate, |
1788 | 1802 | const char *pathname, int *dtype_p) |
1789 | 1803 | { |
1790 | | - struct path_pattern *pattern = |
1791 | | - last_matching_pattern(dir, istate, pathname, dtype_p); |
| 1804 | + struct path_pattern *pattern; |
| 1805 | + |
| 1806 | + if (core_virtualfilesystem) { |
| 1807 | + /* |
| 1808 | + * The virtual file system data is used to prevent git from traversing |
| 1809 | + * any part of the tree that is not in the virtual file system. Return |
| 1810 | + * 1 to exclude the entry if it is not found in the virtual file system, |
| 1811 | + * else fall through to the regular excludes logic as it may further exclude. |
| 1812 | + */ |
| 1813 | + if (*dtype_p == DT_UNKNOWN) |
| 1814 | + *dtype_p = resolve_dtype(DT_UNKNOWN, istate, pathname, strlen(pathname)); |
| 1815 | + if (is_excluded_from_virtualfilesystem(pathname, strlen(pathname), *dtype_p) > 0) |
| 1816 | + return 1; |
| 1817 | + } |
| 1818 | + |
| 1819 | + pattern = last_matching_pattern(dir, istate, pathname, dtype_p); |
1792 | 1820 | if (pattern) |
1793 | 1821 | return pattern->flags & PATTERN_FLAG_NEGATIVE ? 0 : 1; |
1794 | 1822 | return 0; |
@@ -2408,6 +2436,8 @@ static enum path_treatment treat_path(struct dir_struct *dir, |
2408 | 2436 | ignore_case); |
2409 | 2437 | if (dtype != DT_DIR && has_path_in_index) |
2410 | 2438 | return path_none; |
| 2439 | + if (is_excluded_from_virtualfilesystem(path->buf, path->len, dtype) > 0) |
| 2440 | + return path_excluded; |
2411 | 2441 |
|
2412 | 2442 | /* |
2413 | 2443 | * When we are looking at a directory P in the working tree, |
@@ -2612,6 +2642,8 @@ static void add_path_to_appropriate_result_list(struct dir_struct *dir, |
2612 | 2642 | /* add the path to the appropriate result list */ |
2613 | 2643 | switch (state) { |
2614 | 2644 | case path_excluded: |
| 2645 | + if (is_excluded_from_virtualfilesystem(path->buf, path->len, DT_DIR) > 0) |
| 2646 | + break; |
2615 | 2647 | if (dir->flags & DIR_SHOW_IGNORED) |
2616 | 2648 | dir_add_name(dir, istate, path->buf, path->len); |
2617 | 2649 | else if ((dir->flags & DIR_SHOW_IGNORED_TOO) || |
|
0 commit comments