|  | 
| 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" | 
| @@ -1526,6 +1527,19 @@ enum pattern_match_result path_matches_pattern_list( | 
| 1526 | 1527 | 	int result = NOT_MATCHED; | 
| 1527 | 1528 | 	size_t slash_pos; | 
| 1528 | 1529 | 
 | 
|  | 1530 | +	if (core_virtualfilesystem) { | 
|  | 1531 | +		/* | 
|  | 1532 | +		* The virtual file system data is used to prevent git from traversing | 
|  | 1533 | +		* any part of the tree that is not in the virtual file system.  Return | 
|  | 1534 | +		* 1 to exclude the entry if it is not found in the virtual file system, | 
|  | 1535 | +		* else fall through to the regular excludes logic as it may further exclude. | 
|  | 1536 | +		*/ | 
|  | 1537 | +		if (*dtype == DT_UNKNOWN) | 
|  | 1538 | +			*dtype = resolve_dtype(DT_UNKNOWN, istate, pathname, pathlen); | 
|  | 1539 | +		if (is_excluded_from_virtualfilesystem(pathname, pathlen, *dtype) > 0) | 
|  | 1540 | +			return 1; | 
|  | 1541 | +	} | 
|  | 1542 | + | 
| 1529 | 1543 | 	if (!pl->use_cone_patterns) { | 
| 1530 | 1544 | 		pattern = last_matching_pattern_from_list(pathname, pathlen, basename, | 
| 1531 | 1545 | 							dtype, pl, istate); | 
| @@ -1615,6 +1629,13 @@ static int path_in_sparse_checkout_1(const char *path, | 
| 1615 | 1629 | 	enum pattern_match_result match = UNDECIDED; | 
| 1616 | 1630 | 	const char *end, *slash; | 
| 1617 | 1631 | 
 | 
|  | 1632 | +	/* | 
|  | 1633 | +	 * When using a virtual filesystem, there aren't really patterns | 
|  | 1634 | +	 * to follow, but be extra careful to skip this check. | 
|  | 1635 | +	 */ | 
|  | 1636 | +	if (core_virtualfilesystem) | 
|  | 1637 | +		return 1; | 
|  | 1638 | + | 
| 1618 | 1639 | 	/* | 
| 1619 | 1640 | 	 * We default to accepting a path if the path is empty, there are no | 
| 1620 | 1641 | 	 * patterns, or the patterns are of the wrong type. | 
| @@ -1870,8 +1891,22 @@ struct path_pattern *last_matching_pattern(struct dir_struct *dir, | 
| 1870 | 1891 | int is_excluded(struct dir_struct *dir, struct index_state *istate, | 
| 1871 | 1892 | 		const char *pathname, int *dtype_p) | 
| 1872 | 1893 | { | 
| 1873 |  | -	struct path_pattern *pattern = | 
| 1874 |  | -		last_matching_pattern(dir, istate, pathname, dtype_p); | 
|  | 1894 | +	struct path_pattern *pattern; | 
|  | 1895 | + | 
|  | 1896 | +	if (core_virtualfilesystem) { | 
|  | 1897 | +		/* | 
|  | 1898 | +		* The virtual file system data is used to prevent git from traversing | 
|  | 1899 | +		* any part of the tree that is not in the virtual file system.  Return | 
|  | 1900 | +		* 1 to exclude the entry if it is not found in the virtual file system, | 
|  | 1901 | +		* else fall through to the regular excludes logic as it may further exclude. | 
|  | 1902 | +		*/ | 
|  | 1903 | +		if (*dtype_p == DT_UNKNOWN) | 
|  | 1904 | +			*dtype_p = resolve_dtype(DT_UNKNOWN, istate, pathname, strlen(pathname)); | 
|  | 1905 | +		if (is_excluded_from_virtualfilesystem(pathname, strlen(pathname), *dtype_p) > 0) | 
|  | 1906 | +			return 1; | 
|  | 1907 | +	} | 
|  | 1908 | + | 
|  | 1909 | +	pattern = last_matching_pattern(dir, istate, pathname, dtype_p); | 
| 1875 | 1910 | 	if (pattern) | 
| 1876 | 1911 | 		return pattern->flags & PATTERN_FLAG_NEGATIVE ? 0 : 1; | 
| 1877 | 1912 | 	return 0; | 
| @@ -2489,6 +2524,8 @@ static enum path_treatment treat_path(struct dir_struct *dir, | 
| 2489 | 2524 | 						ignore_case); | 
| 2490 | 2525 | 	if (dtype != DT_DIR && has_path_in_index) | 
| 2491 | 2526 | 		return path_none; | 
|  | 2527 | +	if (is_excluded_from_virtualfilesystem(path->buf, path->len, dtype) > 0) | 
|  | 2528 | +		return path_excluded; | 
| 2492 | 2529 | 
 | 
| 2493 | 2530 | 	/* | 
| 2494 | 2531 | 	 * When we are looking at a directory P in the working tree, | 
| @@ -2693,6 +2730,8 @@ static void add_path_to_appropriate_result_list(struct dir_struct *dir, | 
| 2693 | 2730 | 	/* add the path to the appropriate result list */ | 
| 2694 | 2731 | 	switch (state) { | 
| 2695 | 2732 | 	case path_excluded: | 
|  | 2733 | +		if (is_excluded_from_virtualfilesystem(path->buf, path->len, DT_DIR) > 0) | 
|  | 2734 | +			break; | 
| 2696 | 2735 | 		if (dir->flags & DIR_SHOW_IGNORED) | 
| 2697 | 2736 | 			dir_add_name(dir, istate, path->buf, path->len); | 
| 2698 | 2737 | 		else if ((dir->flags & DIR_SHOW_IGNORED_TOO) || | 
|  | 
0 commit comments