|
6 | 6 | * Junio Hamano, 2005-2006 |
7 | 7 | */ |
8 | 8 | #include "cache.h" |
| 9 | +#include "virtualfilesystem.h" |
9 | 10 | #include "config.h" |
10 | 11 | #include "dir.h" |
11 | 12 | #include "object-store.h" |
@@ -1462,6 +1463,17 @@ enum pattern_match_result path_matches_pattern_list( |
1462 | 1463 | int result = NOT_MATCHED; |
1463 | 1464 | size_t slash_pos; |
1464 | 1465 |
|
| 1466 | + /* |
| 1467 | + * The virtual file system data is used to prevent git from traversing |
| 1468 | + * any part of the tree that is not in the virtual file system. Return |
| 1469 | + * 1 to exclude the entry if it is not found in the virtual file system, |
| 1470 | + * else fall through to the regular excludes logic as it may further exclude. |
| 1471 | + */ |
| 1472 | + if (*dtype == DT_UNKNOWN) |
| 1473 | + *dtype = resolve_dtype(DT_UNKNOWN, istate, pathname, pathlen); |
| 1474 | + if (is_excluded_from_virtualfilesystem(pathname, pathlen, *dtype) > 0) |
| 1475 | + return 1; |
| 1476 | + |
1465 | 1477 | if (!pl->use_cone_patterns) { |
1466 | 1478 | pattern = last_matching_pattern_from_list(pathname, pathlen, basename, |
1467 | 1479 | dtype, pl, istate); |
@@ -1804,8 +1816,20 @@ struct path_pattern *last_matching_pattern(struct dir_struct *dir, |
1804 | 1816 | int is_excluded(struct dir_struct *dir, struct index_state *istate, |
1805 | 1817 | const char *pathname, int *dtype_p) |
1806 | 1818 | { |
1807 | | - struct path_pattern *pattern = |
1808 | | - last_matching_pattern(dir, istate, pathname, dtype_p); |
| 1819 | + struct path_pattern *pattern; |
| 1820 | + |
| 1821 | + /* |
| 1822 | + * The virtual file system data is used to prevent git from traversing |
| 1823 | + * any part of the tree that is not in the virtual file system. Return |
| 1824 | + * 1 to exclude the entry if it is not found in the virtual file system, |
| 1825 | + * else fall through to the regular excludes logic as it may further exclude. |
| 1826 | + */ |
| 1827 | + if (*dtype_p == DT_UNKNOWN) |
| 1828 | + *dtype_p = resolve_dtype(DT_UNKNOWN, istate, pathname, strlen(pathname)); |
| 1829 | + if (is_excluded_from_virtualfilesystem(pathname, strlen(pathname), *dtype_p) > 0) |
| 1830 | + return 1; |
| 1831 | + |
| 1832 | + pattern = last_matching_pattern(dir, istate, pathname, dtype_p); |
1809 | 1833 | if (pattern) |
1810 | 1834 | return pattern->flags & PATTERN_FLAG_NEGATIVE ? 0 : 1; |
1811 | 1835 | return 0; |
@@ -2370,6 +2394,8 @@ static enum path_treatment treat_path(struct dir_struct *dir, |
2370 | 2394 | ignore_case); |
2371 | 2395 | if (dtype != DT_DIR && has_path_in_index) |
2372 | 2396 | return path_none; |
| 2397 | + if (is_excluded_from_virtualfilesystem(path->buf, path->len, dtype) > 0) |
| 2398 | + return path_excluded; |
2373 | 2399 |
|
2374 | 2400 | /* |
2375 | 2401 | * When we are looking at a directory P in the working tree, |
@@ -2574,6 +2600,8 @@ static void add_path_to_appropriate_result_list(struct dir_struct *dir, |
2574 | 2600 | /* add the path to the appropriate result list */ |
2575 | 2601 | switch (state) { |
2576 | 2602 | case path_excluded: |
| 2603 | + if (is_excluded_from_virtualfilesystem(path->buf, path->len, DT_DIR) > 0) |
| 2604 | + break; |
2577 | 2605 | if (dir->flags & DIR_SHOW_IGNORED) |
2578 | 2606 | dir_add_name(dir, istate, path->buf, path->len); |
2579 | 2607 | else if ((dir->flags & DIR_SHOW_IGNORED_TOO) || |
|
0 commit comments