|
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" |
@@ -1425,6 +1426,17 @@ enum pattern_match_result path_matches_pattern_list( |
1425 | 1426 | int result = NOT_MATCHED; |
1426 | 1427 | size_t slash_pos; |
1427 | 1428 |
|
| 1429 | + /* |
| 1430 | + * The virtual file system data is used to prevent git from traversing |
| 1431 | + * any part of the tree that is not in the virtual file system. Return |
| 1432 | + * 1 to exclude the entry if it is not found in the virtual file system, |
| 1433 | + * else fall through to the regular excludes logic as it may further exclude. |
| 1434 | + */ |
| 1435 | + if (*dtype == DT_UNKNOWN) |
| 1436 | + *dtype = resolve_dtype(DT_UNKNOWN, istate, pathname, pathlen); |
| 1437 | + if (is_excluded_from_virtualfilesystem(pathname, pathlen, *dtype) > 0) |
| 1438 | + return 1; |
| 1439 | + |
1428 | 1440 | if (!pl->use_cone_patterns) { |
1429 | 1441 | pattern = last_matching_pattern_from_list(pathname, pathlen, basename, |
1430 | 1442 | dtype, pl, istate); |
@@ -1698,8 +1710,20 @@ struct path_pattern *last_matching_pattern(struct dir_struct *dir, |
1698 | 1710 | int is_excluded(struct dir_struct *dir, struct index_state *istate, |
1699 | 1711 | const char *pathname, int *dtype_p) |
1700 | 1712 | { |
1701 | | - struct path_pattern *pattern = |
1702 | | - last_matching_pattern(dir, istate, pathname, dtype_p); |
| 1713 | + struct path_pattern *pattern; |
| 1714 | + |
| 1715 | + /* |
| 1716 | + * The virtual file system data is used to prevent git from traversing |
| 1717 | + * any part of the tree that is not in the virtual file system. Return |
| 1718 | + * 1 to exclude the entry if it is not found in the virtual file system, |
| 1719 | + * else fall through to the regular excludes logic as it may further exclude. |
| 1720 | + */ |
| 1721 | + if (*dtype_p == DT_UNKNOWN) |
| 1722 | + *dtype_p = resolve_dtype(DT_UNKNOWN, istate, pathname, strlen(pathname)); |
| 1723 | + if (is_excluded_from_virtualfilesystem(pathname, strlen(pathname), *dtype_p) > 0) |
| 1724 | + return 1; |
| 1725 | + |
| 1726 | + pattern = last_matching_pattern(dir, istate, pathname, dtype_p); |
1703 | 1727 | if (pattern) |
1704 | 1728 | return pattern->flags & PATTERN_FLAG_NEGATIVE ? 0 : 1; |
1705 | 1729 | return 0; |
@@ -2264,6 +2288,8 @@ static enum path_treatment treat_path(struct dir_struct *dir, |
2264 | 2288 | ignore_case); |
2265 | 2289 | if (dtype != DT_DIR && has_path_in_index) |
2266 | 2290 | return path_none; |
| 2291 | + if (is_excluded_from_virtualfilesystem(path->buf, path->len, dtype) > 0) |
| 2292 | + return path_excluded; |
2267 | 2293 |
|
2268 | 2294 | /* |
2269 | 2295 | * When we are looking at a directory P in the working tree, |
@@ -2468,6 +2494,8 @@ static void add_path_to_appropriate_result_list(struct dir_struct *dir, |
2468 | 2494 | /* add the path to the appropriate result list */ |
2469 | 2495 | switch (state) { |
2470 | 2496 | case path_excluded: |
| 2497 | + if (is_excluded_from_virtualfilesystem(path->buf, path->len, DT_DIR) > 0) |
| 2498 | + break; |
2471 | 2499 | if (dir->flags & DIR_SHOW_IGNORED) |
2472 | 2500 | dir_add_name(dir, istate, path->buf, path->len); |
2473 | 2501 | else if ((dir->flags & DIR_SHOW_IGNORED_TOO) || |
|
0 commit comments