|
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" |
@@ -1414,6 +1415,17 @@ enum pattern_match_result path_matches_pattern_list( |
1414 | 1415 | int result = NOT_MATCHED; |
1415 | 1416 | size_t slash_pos; |
1416 | 1417 |
|
| 1418 | + /* |
| 1419 | + * The virtual file system data is used to prevent git from traversing |
| 1420 | + * any part of the tree that is not in the virtual file system. Return |
| 1421 | + * 1 to exclude the entry if it is not found in the virtual file system, |
| 1422 | + * else fall through to the regular excludes logic as it may further exclude. |
| 1423 | + */ |
| 1424 | + if (*dtype == DT_UNKNOWN) |
| 1425 | + *dtype = resolve_dtype(DT_UNKNOWN, istate, pathname, pathlen); |
| 1426 | + if (is_excluded_from_virtualfilesystem(pathname, pathlen, *dtype) > 0) |
| 1427 | + return 1; |
| 1428 | + |
1417 | 1429 | if (!pl->use_cone_patterns) { |
1418 | 1430 | pattern = last_matching_pattern_from_list(pathname, pathlen, basename, |
1419 | 1431 | dtype, pl, istate); |
@@ -1757,8 +1769,20 @@ struct path_pattern *last_matching_pattern(struct dir_struct *dir, |
1757 | 1769 | int is_excluded(struct dir_struct *dir, struct index_state *istate, |
1758 | 1770 | const char *pathname, int *dtype_p) |
1759 | 1771 | { |
1760 | | - struct path_pattern *pattern = |
1761 | | - last_matching_pattern(dir, istate, pathname, dtype_p); |
| 1772 | + struct path_pattern *pattern; |
| 1773 | + |
| 1774 | + /* |
| 1775 | + * The virtual file system data is used to prevent git from traversing |
| 1776 | + * any part of the tree that is not in the virtual file system. Return |
| 1777 | + * 1 to exclude the entry if it is not found in the virtual file system, |
| 1778 | + * else fall through to the regular excludes logic as it may further exclude. |
| 1779 | + */ |
| 1780 | + if (*dtype_p == DT_UNKNOWN) |
| 1781 | + *dtype_p = resolve_dtype(DT_UNKNOWN, istate, pathname, strlen(pathname)); |
| 1782 | + if (is_excluded_from_virtualfilesystem(pathname, strlen(pathname), *dtype_p) > 0) |
| 1783 | + return 1; |
| 1784 | + |
| 1785 | + pattern = last_matching_pattern(dir, istate, pathname, dtype_p); |
1762 | 1786 | if (pattern) |
1763 | 1787 | return pattern->flags & PATTERN_FLAG_NEGATIVE ? 0 : 1; |
1764 | 1788 | return 0; |
@@ -2344,6 +2368,8 @@ static enum path_treatment treat_path(struct dir_struct *dir, |
2344 | 2368 | ignore_case); |
2345 | 2369 | if (dtype != DT_DIR && has_path_in_index) |
2346 | 2370 | return path_none; |
| 2371 | + if (is_excluded_from_virtualfilesystem(path->buf, path->len, dtype) > 0) |
| 2372 | + return path_excluded; |
2347 | 2373 |
|
2348 | 2374 | /* |
2349 | 2375 | * When we are looking at a directory P in the working tree, |
@@ -2548,6 +2574,8 @@ static void add_path_to_appropriate_result_list(struct dir_struct *dir, |
2548 | 2574 | /* add the path to the appropriate result list */ |
2549 | 2575 | switch (state) { |
2550 | 2576 | case path_excluded: |
| 2577 | + if (is_excluded_from_virtualfilesystem(path->buf, path->len, DT_DIR) > 0) |
| 2578 | + break; |
2551 | 2579 | if (dir->flags & DIR_SHOW_IGNORED) |
2552 | 2580 | dir_add_name(dir, istate, path->buf, path->len); |
2553 | 2581 | else if ((dir->flags & DIR_SHOW_IGNORED_TOO) || |
|
0 commit comments