|
7 | 7 | */
|
8 | 8 | #include "git-compat-util.h"
|
9 | 9 | #include "abspath.h"
|
| 10 | +#include "virtualfilesystem.h" |
10 | 11 | #include "config.h"
|
11 | 12 | #include "convert.h"
|
12 | 13 | #include "dir.h"
|
@@ -1432,6 +1433,17 @@ enum pattern_match_result path_matches_pattern_list(
|
1432 | 1433 | int result = NOT_MATCHED;
|
1433 | 1434 | size_t slash_pos;
|
1434 | 1435 |
|
| 1436 | + /* |
| 1437 | + * The virtual file system data is used to prevent git from traversing |
| 1438 | + * any part of the tree that is not in the virtual file system. Return |
| 1439 | + * 1 to exclude the entry if it is not found in the virtual file system, |
| 1440 | + * else fall through to the regular excludes logic as it may further exclude. |
| 1441 | + */ |
| 1442 | + if (*dtype == DT_UNKNOWN) |
| 1443 | + *dtype = resolve_dtype(DT_UNKNOWN, istate, pathname, pathlen); |
| 1444 | + if (is_excluded_from_virtualfilesystem(pathname, pathlen, *dtype) > 0) |
| 1445 | + return 1; |
| 1446 | + |
1435 | 1447 | if (!pl->use_cone_patterns) {
|
1436 | 1448 | pattern = last_matching_pattern_from_list(pathname, pathlen, basename,
|
1437 | 1449 | dtype, pl, istate);
|
@@ -1776,8 +1788,20 @@ struct path_pattern *last_matching_pattern(struct dir_struct *dir,
|
1776 | 1788 | int is_excluded(struct dir_struct *dir, struct index_state *istate,
|
1777 | 1789 | const char *pathname, int *dtype_p)
|
1778 | 1790 | {
|
1779 |
| - struct path_pattern *pattern = |
1780 |
| - last_matching_pattern(dir, istate, pathname, dtype_p); |
| 1791 | + struct path_pattern *pattern; |
| 1792 | + |
| 1793 | + /* |
| 1794 | + * The virtual file system data is used to prevent git from traversing |
| 1795 | + * any part of the tree that is not in the virtual file system. Return |
| 1796 | + * 1 to exclude the entry if it is not found in the virtual file system, |
| 1797 | + * else fall through to the regular excludes logic as it may further exclude. |
| 1798 | + */ |
| 1799 | + if (*dtype_p == DT_UNKNOWN) |
| 1800 | + *dtype_p = resolve_dtype(DT_UNKNOWN, istate, pathname, strlen(pathname)); |
| 1801 | + if (is_excluded_from_virtualfilesystem(pathname, strlen(pathname), *dtype_p) > 0) |
| 1802 | + return 1; |
| 1803 | + |
| 1804 | + pattern = last_matching_pattern(dir, istate, pathname, dtype_p); |
1781 | 1805 | if (pattern)
|
1782 | 1806 | return pattern->flags & PATTERN_FLAG_NEGATIVE ? 0 : 1;
|
1783 | 1807 | return 0;
|
@@ -2363,6 +2387,8 @@ static enum path_treatment treat_path(struct dir_struct *dir,
|
2363 | 2387 | ignore_case);
|
2364 | 2388 | if (dtype != DT_DIR && has_path_in_index)
|
2365 | 2389 | return path_none;
|
| 2390 | + if (is_excluded_from_virtualfilesystem(path->buf, path->len, dtype) > 0) |
| 2391 | + return path_excluded; |
2366 | 2392 |
|
2367 | 2393 | /*
|
2368 | 2394 | * When we are looking at a directory P in the working tree,
|
@@ -2567,6 +2593,8 @@ static void add_path_to_appropriate_result_list(struct dir_struct *dir,
|
2567 | 2593 | /* add the path to the appropriate result list */
|
2568 | 2594 | switch (state) {
|
2569 | 2595 | case path_excluded:
|
| 2596 | + if (is_excluded_from_virtualfilesystem(path->buf, path->len, DT_DIR) > 0) |
| 2597 | + break; |
2570 | 2598 | if (dir->flags & DIR_SHOW_IGNORED)
|
2571 | 2599 | dir_add_name(dir, istate, path->buf, path->len);
|
2572 | 2600 | else if ((dir->flags & DIR_SHOW_IGNORED_TOO) ||
|
|
0 commit comments