|
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"
|
@@ -1416,6 +1417,17 @@ enum pattern_match_result path_matches_pattern_list(
|
1416 | 1417 | int result = NOT_MATCHED;
|
1417 | 1418 | size_t slash_pos;
|
1418 | 1419 |
|
| 1420 | + /* |
| 1421 | + * The virtual file system data is used to prevent git from traversing |
| 1422 | + * any part of the tree that is not in the virtual file system. Return |
| 1423 | + * 1 to exclude the entry if it is not found in the virtual file system, |
| 1424 | + * else fall through to the regular excludes logic as it may further exclude. |
| 1425 | + */ |
| 1426 | + if (*dtype == DT_UNKNOWN) |
| 1427 | + *dtype = resolve_dtype(DT_UNKNOWN, istate, pathname, pathlen); |
| 1428 | + if (is_excluded_from_virtualfilesystem(pathname, pathlen, *dtype) > 0) |
| 1429 | + return 1; |
| 1430 | + |
1419 | 1431 | if (!pl->use_cone_patterns) {
|
1420 | 1432 | pattern = last_matching_pattern_from_list(pathname, pathlen, basename,
|
1421 | 1433 | dtype, pl, istate);
|
@@ -1759,8 +1771,20 @@ struct path_pattern *last_matching_pattern(struct dir_struct *dir,
|
1759 | 1771 | int is_excluded(struct dir_struct *dir, struct index_state *istate,
|
1760 | 1772 | const char *pathname, int *dtype_p)
|
1761 | 1773 | {
|
1762 |
| - struct path_pattern *pattern = |
1763 |
| - last_matching_pattern(dir, istate, pathname, dtype_p); |
| 1774 | + struct path_pattern *pattern; |
| 1775 | + |
| 1776 | + /* |
| 1777 | + * The virtual file system data is used to prevent git from traversing |
| 1778 | + * any part of the tree that is not in the virtual file system. Return |
| 1779 | + * 1 to exclude the entry if it is not found in the virtual file system, |
| 1780 | + * else fall through to the regular excludes logic as it may further exclude. |
| 1781 | + */ |
| 1782 | + if (*dtype_p == DT_UNKNOWN) |
| 1783 | + *dtype_p = resolve_dtype(DT_UNKNOWN, istate, pathname, strlen(pathname)); |
| 1784 | + if (is_excluded_from_virtualfilesystem(pathname, strlen(pathname), *dtype_p) > 0) |
| 1785 | + return 1; |
| 1786 | + |
| 1787 | + pattern = last_matching_pattern(dir, istate, pathname, dtype_p); |
1764 | 1788 | if (pattern)
|
1765 | 1789 | return pattern->flags & PATTERN_FLAG_NEGATIVE ? 0 : 1;
|
1766 | 1790 | return 0;
|
@@ -2325,6 +2349,8 @@ static enum path_treatment treat_path(struct dir_struct *dir,
|
2325 | 2349 | ignore_case);
|
2326 | 2350 | if (dtype != DT_DIR && has_path_in_index)
|
2327 | 2351 | return path_none;
|
| 2352 | + if (is_excluded_from_virtualfilesystem(path->buf, path->len, dtype) > 0) |
| 2353 | + return path_excluded; |
2328 | 2354 |
|
2329 | 2355 | /*
|
2330 | 2356 | * When we are looking at a directory P in the working tree,
|
@@ -2529,6 +2555,8 @@ static void add_path_to_appropriate_result_list(struct dir_struct *dir,
|
2529 | 2555 | /* add the path to the appropriate result list */
|
2530 | 2556 | switch (state) {
|
2531 | 2557 | case path_excluded:
|
| 2558 | + if (is_excluded_from_virtualfilesystem(path->buf, path->len, DT_DIR) > 0) |
| 2559 | + break; |
2532 | 2560 | if (dir->flags & DIR_SHOW_IGNORED)
|
2533 | 2561 | dir_add_name(dir, istate, path->buf, path->len);
|
2534 | 2562 | else if ((dir->flags & DIR_SHOW_IGNORED_TOO) ||
|
|
0 commit comments