55 */
66#define USE_THE_INDEX_VARIABLE
77#include "cache.h"
8+ #include "environment.h"
89#include "advice.h"
910#include "config.h"
1011#include "builtin.h"
@@ -50,6 +51,7 @@ static int chmod_pathspec(struct pathspec *pathspec, char flip, int show_only)
5051 int err ;
5152
5253 if (!include_sparse &&
54+ !core_virtualfilesystem &&
5355 (ce_skip_worktree (ce ) ||
5456 !path_in_sparse_checkout (ce -> name , & the_index )))
5557 continue ;
@@ -100,7 +102,8 @@ static void update_callback(struct diff_queue_struct *q,
100102 struct diff_filepair * p = q -> queue [i ];
101103 const char * path = p -> one -> path ;
102104
103- if (!include_sparse && !path_in_sparse_checkout (path , & the_index ))
105+ if (!include_sparse && !core_virtualfilesystem &&
106+ !path_in_sparse_checkout (path , & the_index ))
104107 continue ;
105108
106109 switch (fix_unmerged_status (p , data )) {
@@ -219,8 +222,9 @@ static int refresh(int verbose, const struct pathspec *pathspec)
219222 if (!seen [i ]) {
220223 const char * path = pathspec -> items [i ].original ;
221224
222- if (matches_skip_worktree (pathspec , i , & skip_worktree_seen ) ||
223- !path_in_sparse_checkout (path , & the_index )) {
225+ if (!core_virtualfilesystem &&
226+ (matches_skip_worktree (pathspec , i , & skip_worktree_seen ) ||
227+ !path_in_sparse_checkout (path , & the_index ))) {
224228 string_list_append (& only_match_skip_worktree ,
225229 pathspec -> items [i ].original );
226230 } else {
@@ -230,7 +234,11 @@ static int refresh(int verbose, const struct pathspec *pathspec)
230234 }
231235 }
232236
233- if (only_match_skip_worktree .nr ) {
237+ /*
238+ * When using a virtual filesystem, we might re-add a path
239+ * that is currently virtual and we want that to succeed.
240+ */
241+ if (!core_virtualfilesystem && only_match_skip_worktree .nr ) {
234242 advise_on_updating_sparse_paths (& only_match_skip_worktree );
235243 ret = 1 ;
236244 }
@@ -604,7 +612,11 @@ int cmd_add(int argc, const char **argv, const char *prefix)
604612 if (seen [i ])
605613 continue ;
606614
607- if (!include_sparse &&
615+ /*
616+ * When using a virtual filesystem, we might re-add a path
617+ * that is currently virtual and we want that to succeed.
618+ */
619+ if (!include_sparse && !core_virtualfilesystem &&
608620 matches_skip_worktree (& pathspec , i , & skip_worktree_seen )) {
609621 string_list_append (& only_match_skip_worktree ,
610622 pathspec .items [i ].original );
@@ -628,7 +640,6 @@ int cmd_add(int argc, const char **argv, const char *prefix)
628640 }
629641 }
630642
631-
632643 if (only_match_skip_worktree .nr ) {
633644 advise_on_updating_sparse_paths (& only_match_skip_worktree );
634645 exit_status = 1 ;
0 commit comments