|
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"
|
@@ -1419,6 +1420,17 @@ enum pattern_match_result path_matches_pattern_list(
|
1419 | 1420 | int result = NOT_MATCHED;
|
1420 | 1421 | size_t slash_pos;
|
1421 | 1422 |
|
| 1423 | + /* |
| 1424 | + * The virtual file system data is used to prevent git from traversing |
| 1425 | + * any part of the tree that is not in the virtual file system. Return |
| 1426 | + * 1 to exclude the entry if it is not found in the virtual file system, |
| 1427 | + * else fall through to the regular excludes logic as it may further exclude. |
| 1428 | + */ |
| 1429 | + if (*dtype == DT_UNKNOWN) |
| 1430 | + *dtype = resolve_dtype(DT_UNKNOWN, istate, pathname, pathlen); |
| 1431 | + if (is_excluded_from_virtualfilesystem(pathname, pathlen, *dtype) > 0) |
| 1432 | + return 1; |
| 1433 | + |
1422 | 1434 | if (!pl->use_cone_patterns) {
|
1423 | 1435 | pattern = last_matching_pattern_from_list(pathname, pathlen, basename,
|
1424 | 1436 | dtype, pl, istate);
|
@@ -1762,8 +1774,20 @@ struct path_pattern *last_matching_pattern(struct dir_struct *dir,
|
1762 | 1774 | int is_excluded(struct dir_struct *dir, struct index_state *istate,
|
1763 | 1775 | const char *pathname, int *dtype_p)
|
1764 | 1776 | {
|
1765 |
| - struct path_pattern *pattern = |
1766 |
| - last_matching_pattern(dir, istate, pathname, dtype_p); |
| 1777 | + struct path_pattern *pattern; |
| 1778 | + |
| 1779 | + /* |
| 1780 | + * The virtual file system data is used to prevent git from traversing |
| 1781 | + * any part of the tree that is not in the virtual file system. Return |
| 1782 | + * 1 to exclude the entry if it is not found in the virtual file system, |
| 1783 | + * else fall through to the regular excludes logic as it may further exclude. |
| 1784 | + */ |
| 1785 | + if (*dtype_p == DT_UNKNOWN) |
| 1786 | + *dtype_p = resolve_dtype(DT_UNKNOWN, istate, pathname, strlen(pathname)); |
| 1787 | + if (is_excluded_from_virtualfilesystem(pathname, strlen(pathname), *dtype_p) > 0) |
| 1788 | + return 1; |
| 1789 | + |
| 1790 | + pattern = last_matching_pattern(dir, istate, pathname, dtype_p); |
1767 | 1791 | if (pattern)
|
1768 | 1792 | return pattern->flags & PATTERN_FLAG_NEGATIVE ? 0 : 1;
|
1769 | 1793 | return 0;
|
@@ -2349,6 +2373,8 @@ static enum path_treatment treat_path(struct dir_struct *dir,
|
2349 | 2373 | ignore_case);
|
2350 | 2374 | if (dtype != DT_DIR && has_path_in_index)
|
2351 | 2375 | return path_none;
|
| 2376 | + if (is_excluded_from_virtualfilesystem(path->buf, path->len, dtype) > 0) |
| 2377 | + return path_excluded; |
2352 | 2378 |
|
2353 | 2379 | /*
|
2354 | 2380 | * When we are looking at a directory P in the working tree,
|
@@ -2553,6 +2579,8 @@ static void add_path_to_appropriate_result_list(struct dir_struct *dir,
|
2553 | 2579 | /* add the path to the appropriate result list */
|
2554 | 2580 | switch (state) {
|
2555 | 2581 | case path_excluded:
|
| 2582 | + if (is_excluded_from_virtualfilesystem(path->buf, path->len, DT_DIR) > 0) |
| 2583 | + break; |
2556 | 2584 | if (dir->flags & DIR_SHOW_IGNORED)
|
2557 | 2585 | dir_add_name(dir, istate, path->buf, path->len);
|
2558 | 2586 | else if ((dir->flags & DIR_SHOW_IGNORED_TOO) ||
|
|
0 commit comments