diff --git a/builtin/add.c b/builtin/add.c index fc2866fad8afbe..d85b2bd81974d7 100644 --- a/builtin/add.c +++ b/builtin/add.c @@ -1,3 +1,5 @@ +#define USE_THE_REPOSITORY_VARIABLE + /* * "git add" builtin command * @@ -5,6 +7,7 @@ */ #include "builtin.h" +#include "environment.h" #include "advice.h" #include "config.h" #include "lockfile.h" @@ -47,6 +50,7 @@ static int chmod_pathspec(struct repository *repo, int err; if (!include_sparse && + !core_virtualfilesystem && (ce_skip_worktree(ce) || !path_in_sparse_checkout(ce->name, repo->index))) continue; @@ -132,8 +136,9 @@ static int refresh(struct repository *repo, int verbose, const struct pathspec * if (!seen[i]) { const char *path = pathspec->items[i].original; - if (matches_skip_worktree(pathspec, i, &skip_worktree_seen) || - !path_in_sparse_checkout(path, repo->index)) { + if (!core_virtualfilesystem && + (matches_skip_worktree(pathspec, i, &skip_worktree_seen) || + !path_in_sparse_checkout(path, repo->index))) { string_list_append(&only_match_skip_worktree, pathspec->items[i].original); } else { @@ -143,7 +148,11 @@ static int refresh(struct repository *repo, int verbose, const struct pathspec * } } - if (only_match_skip_worktree.nr) { + /* + * When using a virtual filesystem, we might re-add a path + * that is currently virtual and we want that to succeed. + */ + if (!core_virtualfilesystem && only_match_skip_worktree.nr) { advise_on_updating_sparse_paths(&only_match_skip_worktree); ret = 1; } @@ -529,7 +538,11 @@ int cmd_add(int argc, if (seen[i]) continue; - if (!include_sparse && + /* + * When using a virtual filesystem, we might re-add a path + * that is currently virtual and we want that to succeed. + */ + if (!include_sparse && !core_virtualfilesystem && matches_skip_worktree(&pathspec, i, &skip_worktree_seen)) { string_list_append(&only_match_skip_worktree, pathspec.items[i].original); @@ -553,7 +566,6 @@ int cmd_add(int argc, } } - if (only_match_skip_worktree.nr) { advise_on_updating_sparse_paths(&only_match_skip_worktree); exit_status = 1; diff --git a/builtin/rm.c b/builtin/rm.c index 12ae086a556ce3..67a1cea2226747 100644 --- a/builtin/rm.c +++ b/builtin/rm.c @@ -8,6 +8,7 @@ #define DISABLE_SIGN_COMPARE_WARNINGS #include "builtin.h" +#include "environment.h" #include "advice.h" #include "config.h" #include "lockfile.h" @@ -317,7 +318,7 @@ int cmd_rm(int argc, for (i = 0; i < the_repository->index->cache_nr; i++) { const struct cache_entry *ce = the_repository->index->cache[i]; - if (!include_sparse && + if (!include_sparse && !core_virtualfilesystem && (ce_skip_worktree(ce) || !path_in_sparse_checkout(ce->name, the_repository->index))) continue; @@ -354,7 +355,11 @@ int cmd_rm(int argc, *original ? original : "."); } - if (only_match_skip_worktree.nr) { + /* + * When using a virtual filesystem, we might re-add a path + * that is currently virtual and we want that to succeed. + */ + if (!core_virtualfilesystem && only_match_skip_worktree.nr) { advise_on_updating_sparse_paths(&only_match_skip_worktree); ret = 1; } diff --git a/read-cache.c b/read-cache.c index ce3abdb063f208..e9994d00f3fca1 100644 --- a/read-cache.c +++ b/read-cache.c @@ -3971,7 +3971,7 @@ static void update_callback(struct diff_queue_struct *q, struct diff_filepair *p = q->queue[i]; const char *path = p->one->path; - if (!data->include_sparse && + if (!data->include_sparse && !core_virtualfilesystem && !path_in_sparse_checkout(path, data->index)) continue;