|
11 | 11 |
|
12 | 12 | #include "git-compat-util.h" |
13 | 13 | #include "abspath.h" |
| 14 | +#include "virtualfilesystem.h" |
14 | 15 | #include "config.h" |
15 | 16 | #include "convert.h" |
16 | 17 | #include "dir.h" |
@@ -1533,6 +1534,19 @@ enum pattern_match_result path_matches_pattern_list( |
1533 | 1534 | int result = NOT_MATCHED; |
1534 | 1535 | size_t slash_pos; |
1535 | 1536 |
|
| 1537 | + if (core_virtualfilesystem) { |
| 1538 | + /* |
| 1539 | + * The virtual file system data is used to prevent git from traversing |
| 1540 | + * any part of the tree that is not in the virtual file system. Return |
| 1541 | + * 1 to exclude the entry if it is not found in the virtual file system, |
| 1542 | + * else fall through to the regular excludes logic as it may further exclude. |
| 1543 | + */ |
| 1544 | + if (*dtype == DT_UNKNOWN) |
| 1545 | + *dtype = resolve_dtype(DT_UNKNOWN, istate, pathname, pathlen); |
| 1546 | + if (is_excluded_from_virtualfilesystem(pathname, pathlen, *dtype) > 0) |
| 1547 | + return 1; |
| 1548 | + } |
| 1549 | + |
1536 | 1550 | if (!pl->use_cone_patterns) { |
1537 | 1551 | pattern = last_matching_pattern_from_list(pathname, pathlen, basename, |
1538 | 1552 | dtype, pl, istate); |
@@ -1622,6 +1636,13 @@ static int path_in_sparse_checkout_1(const char *path, |
1622 | 1636 | enum pattern_match_result match = UNDECIDED; |
1623 | 1637 | const char *end, *slash; |
1624 | 1638 |
|
| 1639 | + /* |
| 1640 | + * When using a virtual filesystem, there aren't really patterns |
| 1641 | + * to follow, but be extra careful to skip this check. |
| 1642 | + */ |
| 1643 | + if (core_virtualfilesystem) |
| 1644 | + return 1; |
| 1645 | + |
1625 | 1646 | /* |
1626 | 1647 | * We default to accepting a path if the path is empty, there are no |
1627 | 1648 | * patterns, or the patterns are of the wrong type. |
@@ -1877,8 +1898,22 @@ struct path_pattern *last_matching_pattern(struct dir_struct *dir, |
1877 | 1898 | int is_excluded(struct dir_struct *dir, struct index_state *istate, |
1878 | 1899 | const char *pathname, int *dtype_p) |
1879 | 1900 | { |
1880 | | - struct path_pattern *pattern = |
1881 | | - last_matching_pattern(dir, istate, pathname, dtype_p); |
| 1901 | + struct path_pattern *pattern; |
| 1902 | + |
| 1903 | + if (core_virtualfilesystem) { |
| 1904 | + /* |
| 1905 | + * The virtual file system data is used to prevent git from traversing |
| 1906 | + * any part of the tree that is not in the virtual file system. Return |
| 1907 | + * 1 to exclude the entry if it is not found in the virtual file system, |
| 1908 | + * else fall through to the regular excludes logic as it may further exclude. |
| 1909 | + */ |
| 1910 | + if (*dtype_p == DT_UNKNOWN) |
| 1911 | + *dtype_p = resolve_dtype(DT_UNKNOWN, istate, pathname, strlen(pathname)); |
| 1912 | + if (is_excluded_from_virtualfilesystem(pathname, strlen(pathname), *dtype_p) > 0) |
| 1913 | + return 1; |
| 1914 | + } |
| 1915 | + |
| 1916 | + pattern = last_matching_pattern(dir, istate, pathname, dtype_p); |
1882 | 1917 | if (pattern) |
1883 | 1918 | return pattern->flags & PATTERN_FLAG_NEGATIVE ? 0 : 1; |
1884 | 1919 | return 0; |
@@ -2496,6 +2531,8 @@ static enum path_treatment treat_path(struct dir_struct *dir, |
2496 | 2531 | ignore_case); |
2497 | 2532 | if (dtype != DT_DIR && has_path_in_index) |
2498 | 2533 | return path_none; |
| 2534 | + if (is_excluded_from_virtualfilesystem(path->buf, path->len, dtype) > 0) |
| 2535 | + return path_excluded; |
2499 | 2536 |
|
2500 | 2537 | /* |
2501 | 2538 | * When we are looking at a directory P in the working tree, |
@@ -2700,6 +2737,8 @@ static void add_path_to_appropriate_result_list(struct dir_struct *dir, |
2700 | 2737 | /* add the path to the appropriate result list */ |
2701 | 2738 | switch (state) { |
2702 | 2739 | case path_excluded: |
| 2740 | + if (is_excluded_from_virtualfilesystem(path->buf, path->len, DT_DIR) > 0) |
| 2741 | + break; |
2703 | 2742 | if (dir->flags & DIR_SHOW_IGNORED) |
2704 | 2743 | dir_add_name(dir, istate, path->buf, path->len); |
2705 | 2744 | else if ((dir->flags & DIR_SHOW_IGNORED_TOO) || |
|
0 commit comments