|
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" |
@@ -1421,6 +1422,17 @@ enum pattern_match_result path_matches_pattern_list( |
1421 | 1422 | int result = NOT_MATCHED; |
1422 | 1423 | const char *slash_pos; |
1423 | 1424 |
|
| 1425 | + /* |
| 1426 | + * The virtual file system data is used to prevent git from traversing |
| 1427 | + * any part of the tree that is not in the virtual file system. Return |
| 1428 | + * 1 to exclude the entry if it is not found in the virtual file system, |
| 1429 | + * else fall through to the regular excludes logic as it may further exclude. |
| 1430 | + */ |
| 1431 | + if (*dtype == DT_UNKNOWN) |
| 1432 | + *dtype = resolve_dtype(DT_UNKNOWN, istate, pathname, pathlen); |
| 1433 | + if (is_excluded_from_virtualfilesystem(pathname, pathlen, *dtype) > 0) |
| 1434 | + return 1; |
| 1435 | + |
1424 | 1436 | if (!pl->use_cone_patterns) { |
1425 | 1437 | pattern = last_matching_pattern_from_list(pathname, pathlen, basename, |
1426 | 1438 | dtype, pl, istate); |
@@ -1680,8 +1692,20 @@ struct path_pattern *last_matching_pattern(struct dir_struct *dir, |
1680 | 1692 | int is_excluded(struct dir_struct *dir, struct index_state *istate, |
1681 | 1693 | const char *pathname, int *dtype_p) |
1682 | 1694 | { |
1683 | | - struct path_pattern *pattern = |
1684 | | - last_matching_pattern(dir, istate, pathname, dtype_p); |
| 1695 | + struct path_pattern *pattern; |
| 1696 | + |
| 1697 | + /* |
| 1698 | + * The virtual file system data is used to prevent git from traversing |
| 1699 | + * any part of the tree that is not in the virtual file system. Return |
| 1700 | + * 1 to exclude the entry if it is not found in the virtual file system, |
| 1701 | + * else fall through to the regular excludes logic as it may further exclude. |
| 1702 | + */ |
| 1703 | + if (*dtype_p == DT_UNKNOWN) |
| 1704 | + *dtype_p = resolve_dtype(DT_UNKNOWN, istate, pathname, strlen(pathname)); |
| 1705 | + if (is_excluded_from_virtualfilesystem(pathname, strlen(pathname), *dtype_p) > 0) |
| 1706 | + return 1; |
| 1707 | + |
| 1708 | + pattern = last_matching_pattern(dir, istate, pathname, dtype_p); |
1685 | 1709 | if (pattern) |
1686 | 1710 | return pattern->flags & PATTERN_FLAG_NEGATIVE ? 0 : 1; |
1687 | 1711 | return 0; |
@@ -2246,6 +2270,8 @@ static enum path_treatment treat_path(struct dir_struct *dir, |
2246 | 2270 | ignore_case); |
2247 | 2271 | if (dtype != DT_DIR && has_path_in_index) |
2248 | 2272 | return path_none; |
| 2273 | + if (is_excluded_from_virtualfilesystem(path->buf, path->len, dtype) > 0) |
| 2274 | + return path_excluded; |
2249 | 2275 |
|
2250 | 2276 | /* |
2251 | 2277 | * When we are looking at a directory P in the working tree, |
@@ -2450,6 +2476,8 @@ static void add_path_to_appropriate_result_list(struct dir_struct *dir, |
2450 | 2476 | /* add the path to the appropriate result list */ |
2451 | 2477 | switch (state) { |
2452 | 2478 | case path_excluded: |
| 2479 | + if (is_excluded_from_virtualfilesystem(path->buf, path->len, DT_DIR) > 0) |
| 2480 | + break; |
2453 | 2481 | if (dir->flags & DIR_SHOW_IGNORED) |
2454 | 2482 | dir_add_name(dir, istate, path->buf, path->len); |
2455 | 2483 | else if ((dir->flags & DIR_SHOW_IGNORED_TOO) || |
|
0 commit comments