зеркало из https://github.com/microsoft/git.git
Merge pull request #392: add: allow adding sparse entries when virtual
Upstream, a20f704
(add: warn when asked to update SKIP_WORKTREE entries,
04-08-2021) modified how 'git add <pathspec>' works with cache entries
marked with the SKIP_WORKTREE bit. The intention is to prevent a user
from accidentally adding a path that is outside their sparse-checkout
definition but somehow matches an existing index entry.
This breaks when using the virtual filesystem in VFS for Git. It is
rare, but we could be in a scenario where the user has staged a change
and then the file is projected away. If the user re-adds the file, then
this warning causes the command to fail with the advise message.
Disable this logic when core_virtualfilesystem is enabled.
This should allow the VFS for Git functional tests to pass (at least
the ones in the default run). I'll create a `-pr` installer build to
check before merging this.
This commit is contained in:
Коммит
4879efa501
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
#define USE_THE_INDEX_VARIABLE
|
||||
#include "builtin.h"
|
||||
#include "environment.h"
|
||||
#include "advice.h"
|
||||
#include "config.h"
|
||||
#include "lockfile.h"
|
||||
|
@ -45,6 +46,7 @@ static int chmod_pathspec(struct pathspec *pathspec, char flip, int show_only)
|
|||
int err;
|
||||
|
||||
if (!include_sparse &&
|
||||
!core_virtualfilesystem &&
|
||||
(ce_skip_worktree(ce) ||
|
||||
!path_in_sparse_checkout(ce->name, &the_index)))
|
||||
continue;
|
||||
|
@ -125,8 +127,9 @@ static int refresh(int verbose, const struct pathspec *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, &the_index)) {
|
||||
if (!core_virtualfilesystem &&
|
||||
(matches_skip_worktree(pathspec, i, &skip_worktree_seen) ||
|
||||
!path_in_sparse_checkout(path, &the_index))) {
|
||||
string_list_append(&only_match_skip_worktree,
|
||||
pathspec->items[i].original);
|
||||
} else {
|
||||
|
@ -136,7 +139,11 @@ static int refresh(int verbose, const struct pathspec *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;
|
||||
}
|
||||
|
@ -516,7 +523,11 @@ int cmd_add(int argc, const char **argv, const char *prefix)
|
|||
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);
|
||||
|
@ -540,7 +551,6 @@ int cmd_add(int argc, const char **argv, const char *prefix)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
if (only_match_skip_worktree.nr) {
|
||||
advise_on_updating_sparse_paths(&only_match_skip_worktree);
|
||||
exit_status = 1;
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
#define USE_THE_INDEX_VARIABLE
|
||||
#include "builtin.h"
|
||||
#include "environment.h"
|
||||
#include "advice.h"
|
||||
#include "config.h"
|
||||
#include "lockfile.h"
|
||||
|
@ -311,7 +312,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
|
|||
for (i = 0; i < the_index.cache_nr; i++) {
|
||||
const struct cache_entry *ce = the_index.cache[i];
|
||||
|
||||
if (!include_sparse &&
|
||||
if (!include_sparse && !core_virtualfilesystem &&
|
||||
(ce_skip_worktree(ce) ||
|
||||
!path_in_sparse_checkout(ce->name, &the_index)))
|
||||
continue;
|
||||
|
@ -348,7 +349,11 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
|
|||
*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;
|
||||
}
|
||||
|
|
|
@ -3934,7 +3934,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;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче