|
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" |
@@ -1431,6 +1432,17 @@ enum pattern_match_result path_matches_pattern_list( |
1431 | 1432 | int result = NOT_MATCHED; |
1432 | 1433 | size_t slash_pos; |
1433 | 1434 |
|
| 1435 | + /* |
| 1436 | + * The virtual file system data is used to prevent git from traversing |
| 1437 | + * any part of the tree that is not in the virtual file system. Return |
| 1438 | + * 1 to exclude the entry if it is not found in the virtual file system, |
| 1439 | + * else fall through to the regular excludes logic as it may further exclude. |
| 1440 | + */ |
| 1441 | + if (*dtype == DT_UNKNOWN) |
| 1442 | + *dtype = resolve_dtype(DT_UNKNOWN, istate, pathname, pathlen); |
| 1443 | + if (is_excluded_from_virtualfilesystem(pathname, pathlen, *dtype) > 0) |
| 1444 | + return 1; |
| 1445 | + |
1434 | 1446 | if (!pl->use_cone_patterns) { |
1435 | 1447 | pattern = last_matching_pattern_from_list(pathname, pathlen, basename, |
1436 | 1448 | dtype, pl, istate); |
@@ -1775,8 +1787,20 @@ struct path_pattern *last_matching_pattern(struct dir_struct *dir, |
1775 | 1787 | int is_excluded(struct dir_struct *dir, struct index_state *istate, |
1776 | 1788 | const char *pathname, int *dtype_p) |
1777 | 1789 | { |
1778 | | - struct path_pattern *pattern = |
1779 | | - last_matching_pattern(dir, istate, pathname, dtype_p); |
| 1790 | + struct path_pattern *pattern; |
| 1791 | + |
| 1792 | + /* |
| 1793 | + * The virtual file system data is used to prevent git from traversing |
| 1794 | + * any part of the tree that is not in the virtual file system. Return |
| 1795 | + * 1 to exclude the entry if it is not found in the virtual file system, |
| 1796 | + * else fall through to the regular excludes logic as it may further exclude. |
| 1797 | + */ |
| 1798 | + if (*dtype_p == DT_UNKNOWN) |
| 1799 | + *dtype_p = resolve_dtype(DT_UNKNOWN, istate, pathname, strlen(pathname)); |
| 1800 | + if (is_excluded_from_virtualfilesystem(pathname, strlen(pathname), *dtype_p) > 0) |
| 1801 | + return 1; |
| 1802 | + |
| 1803 | + pattern = last_matching_pattern(dir, istate, pathname, dtype_p); |
1780 | 1804 | if (pattern) |
1781 | 1805 | return pattern->flags & PATTERN_FLAG_NEGATIVE ? 0 : 1; |
1782 | 1806 | return 0; |
@@ -2396,6 +2420,8 @@ static enum path_treatment treat_path(struct dir_struct *dir, |
2396 | 2420 | ignore_case); |
2397 | 2421 | if (dtype != DT_DIR && has_path_in_index) |
2398 | 2422 | return path_none; |
| 2423 | + if (is_excluded_from_virtualfilesystem(path->buf, path->len, dtype) > 0) |
| 2424 | + return path_excluded; |
2399 | 2425 |
|
2400 | 2426 | /* |
2401 | 2427 | * When we are looking at a directory P in the working tree, |
@@ -2600,6 +2626,8 @@ static void add_path_to_appropriate_result_list(struct dir_struct *dir, |
2600 | 2626 | /* add the path to the appropriate result list */ |
2601 | 2627 | switch (state) { |
2602 | 2628 | case path_excluded: |
| 2629 | + if (is_excluded_from_virtualfilesystem(path->buf, path->len, DT_DIR) > 0) |
| 2630 | + break; |
2603 | 2631 | if (dir->flags & DIR_SHOW_IGNORED) |
2604 | 2632 | dir_add_name(dir, istate, path->buf, path->len); |
2605 | 2633 | else if ((dir->flags & DIR_SHOW_IGNORED_TOO) || |
|
0 commit comments