@@ -47,6 +47,7 @@ static int chmod_pathspec(struct pathspec *pathspec, char flip, int show_only)
4747 int err ;
4848
4949 if (!include_sparse &&
50+ !core_virtualfilesystem &&
5051 (ce_skip_worktree (ce ) ||
5152 !path_in_sparse_checkout (ce -> name , & the_index )))
5253 continue ;
@@ -97,7 +98,8 @@ static void update_callback(struct diff_queue_struct *q,
9798 struct diff_filepair * p = q -> queue [i ];
9899 const char * path = p -> one -> path ;
99100
100- if (!include_sparse && !path_in_sparse_checkout (path , & the_index ))
101+ if (!include_sparse && !core_virtualfilesystem &&
102+ !path_in_sparse_checkout (path , & the_index ))
101103 continue ;
102104
103105 switch (fix_unmerged_status (p , data )) {
@@ -215,8 +217,9 @@ static int refresh(int verbose, const struct pathspec *pathspec)
215217 if (!seen [i ]) {
216218 const char * path = pathspec -> items [i ].original ;
217219
218- if (matches_skip_worktree (pathspec , i , & skip_worktree_seen ) ||
219- !path_in_sparse_checkout (path , & the_index )) {
220+ if (!core_virtualfilesystem &&
221+ (matches_skip_worktree (pathspec , i , & skip_worktree_seen ) ||
222+ !path_in_sparse_checkout (path , & the_index ))) {
220223 string_list_append (& only_match_skip_worktree ,
221224 pathspec -> items [i ].original );
222225 } else {
@@ -226,7 +229,11 @@ static int refresh(int verbose, const struct pathspec *pathspec)
226229 }
227230 }
228231
229- if (only_match_skip_worktree .nr ) {
232+ /*
233+ * When using a virtual filesystem, we might re-add a path
234+ * that is currently virtual and we want that to succeed.
235+ */
236+ if (!core_virtualfilesystem && only_match_skip_worktree .nr ) {
230237 advise_on_updating_sparse_paths (& only_match_skip_worktree );
231238 ret = 1 ;
232239 }
@@ -644,7 +651,11 @@ int cmd_add(int argc, const char **argv, const char *prefix)
644651 if (seen [i ])
645652 continue ;
646653
647- if (!include_sparse &&
654+ /*
655+ * When using a virtual filesystem, we might re-add a path
656+ * that is currently virtual and we want that to succeed.
657+ */
658+ if (!include_sparse && !core_virtualfilesystem &&
648659 matches_skip_worktree (& pathspec , i , & skip_worktree_seen )) {
649660 string_list_append (& only_match_skip_worktree ,
650661 pathspec .items [i ].original );
@@ -668,7 +679,6 @@ int cmd_add(int argc, const char **argv, const char *prefix)
668679 }
669680 }
670681
671-
672682 if (only_match_skip_worktree .nr ) {
673683 advise_on_updating_sparse_paths (& only_match_skip_worktree );
674684 exit_status = 1 ;
0 commit comments