|
20 | 20 | #include "ewah/ewok.h" |
21 | 21 | #include "fsmonitor.h" |
22 | 22 | #include "submodule-config.h" |
| 23 | +#include "virtualfilesystem.h" |
23 | 24 |
|
24 | 25 | /* |
25 | 26 | * Tells read_directory_recursive how a file or directory should be treated. |
@@ -1121,6 +1122,18 @@ int is_excluded_from_list(const char *pathname, |
1121 | 1122 | struct exclude_list *el, struct index_state *istate) |
1122 | 1123 | { |
1123 | 1124 | struct exclude *exclude; |
| 1125 | + |
| 1126 | + /* |
| 1127 | + * The virtual file system data is used to prevent git from traversing |
| 1128 | + * any part of the tree that is not in the virtual file system. Return |
| 1129 | + * 1 to exclude the entry if it is not found in the virtual file system, |
| 1130 | + * else fall through to the regular excludes logic as it may further exclude. |
| 1131 | + */ |
| 1132 | + if (*dtype == DT_UNKNOWN) |
| 1133 | + *dtype = get_dtype(NULL, istate, pathname, pathlen); |
| 1134 | + if (is_excluded_from_virtualfilesystem(pathname, pathlen, *dtype) > 0) |
| 1135 | + return 1; |
| 1136 | + |
1124 | 1137 | exclude = last_exclude_matching_from_list(pathname, pathlen, basename, |
1125 | 1138 | dtype, el, istate); |
1126 | 1139 | if (exclude) |
@@ -1336,8 +1349,20 @@ struct exclude *last_exclude_matching(struct dir_struct *dir, |
1336 | 1349 | int is_excluded(struct dir_struct *dir, struct index_state *istate, |
1337 | 1350 | const char *pathname, int *dtype_p) |
1338 | 1351 | { |
1339 | | - struct exclude *exclude = |
1340 | | - last_exclude_matching(dir, istate, pathname, dtype_p); |
| 1352 | + struct exclude *exclude; |
| 1353 | + |
| 1354 | + /* |
| 1355 | + * The virtual file system data is used to prevent git from traversing |
| 1356 | + * any part of the tree that is not in the virtual file system. Return |
| 1357 | + * 1 to exclude the entry if it is not found in the virtual file system, |
| 1358 | + * else fall through to the regular excludes logic as it may further exclude. |
| 1359 | + */ |
| 1360 | + if (*dtype_p == DT_UNKNOWN) |
| 1361 | + *dtype_p = get_dtype(NULL, istate, pathname, strlen(pathname)); |
| 1362 | + if (is_excluded_from_virtualfilesystem(pathname, strlen(pathname), *dtype_p) > 0) |
| 1363 | + return 1; |
| 1364 | + |
| 1365 | + exclude = last_exclude_matching(dir, istate, pathname, dtype_p); |
1341 | 1366 | if (exclude) |
1342 | 1367 | return exclude->flags & EXC_FLAG_NEGATIVE ? 0 : 1; |
1343 | 1368 | return 0; |
@@ -1690,6 +1715,9 @@ static enum path_treatment treat_one_path(struct dir_struct *dir, |
1690 | 1715 | if (dtype != DT_DIR && has_path_in_index) |
1691 | 1716 | return path_none; |
1692 | 1717 |
|
| 1718 | + if (is_excluded_from_virtualfilesystem(path->buf, path->len, dtype) > 0) |
| 1719 | + return path_excluded; |
| 1720 | + |
1693 | 1721 | /* |
1694 | 1722 | * When we are looking at a directory P in the working tree, |
1695 | 1723 | * there are three cases: |
@@ -2030,6 +2058,8 @@ static enum path_treatment read_directory_recursive(struct dir_struct *dir, |
2030 | 2058 | /* add the path to the appropriate result list */ |
2031 | 2059 | switch (state) { |
2032 | 2060 | case path_excluded: |
| 2061 | + if (is_excluded_from_virtualfilesystem(path.buf, path.len, DT_DIR) > 0) |
| 2062 | + break; |
2033 | 2063 | if (dir->flags & DIR_SHOW_IGNORED) |
2034 | 2064 | dir_add_name(dir, istate, path.buf, path.len); |
2035 | 2065 | else if ((dir->flags & DIR_SHOW_IGNORED_TOO) || |
|
0 commit comments