Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DO NOT MERGE BUT PUSH INSTEAD] Rebase to v2.42.0 #596

Merged
merged 206 commits into from
Aug 23, 2023
Merged
Changes from 2 commits
Commits
Show all changes
206 commits
Select commit Hold shift + click to select a range
beb3ce9
reset --stdin: trim carriage return from the paths
Apr 5, 2017
83d4652
gvfs: start by adding the -gvfs suffix to the version
sanoursa Jan 24, 2017
6963153
gvfs: ensure that the version is based on a GVFS tag
dscho Apr 4, 2017
7fa2270
gvfs: add a GVFS-specific header file
Jan 24, 2017
b9b41d5
gvfs: add the core.gvfs config setting
Jan 24, 2017
85c245d
gvfs: add the feature to skip writing the index' SHA-1
Jan 24, 2017
b75bb69
gvfs: add the feature that blobs may be missing
Jan 24, 2017
5defb61
gvfs: prevent files to be deleted outside the sparse checkout
May 18, 2016
2989380
gvfs: optionally skip reachability checks/upload pack during fetch
May 30, 2016
7027220
gvfs: add global command pre and post hook procs
May 24, 2016
fd78c60
gvfs: ensure all filters and EOL conversions are blocked
Jun 15, 2016
a04260e
t0400: verify that the hook is called correctly from a subdirectory
dscho Mar 16, 2017
6be8f17
gvfs: allow "virtualizing" objects
Jan 10, 2017
1a14559
Pass PID of git process to hooks.
alepauly Apr 10, 2017
ba8ff26
Hydrate missing loose objects in check_and_freshen()
Mar 15, 2017
638cebd
pre-command: always respect core.hooksPath
dscho Aug 7, 2017
a05336f
sha1_file: when writing objects, skip the read_object_hook
dscho Sep 8, 2017
ab7419d
sparse-checkout: update files with a modify/delete conflict
Feb 22, 2017
fc24c98
sparse-checkout: avoid writing entries with the skip-worktree bit
Mar 1, 2017
99f8539
Do not remove files outside the sparse-checkout
Apr 5, 2017
b1e77b3
gvfs: refactor loading the core.gvfs config value
Apr 14, 2017
789bfe2
send-pack: do not check for sha1 file when GVFS_MISSING_OK set
Nov 16, 2018
7abe226
cache-tree: remove use of strbuf_addf in update_one
Jul 3, 2017
f4489d5
gvfs: block unsupported commands when running in a GVFS repo
benpeart Dec 6, 2018
b2db477
worktree: allow in Scalar repositories
derrickstolee Sep 30, 2022
6045bcc
gvfs: allow overriding core.gvfs
derrickstolee Apr 15, 2020
6745c45
Add virtual file system settings and hook proc
benpeart Jan 11, 2018
523c9ca
virtualfilesystem: don't run the virtual file system hook if the inde…
benpeart Aug 1, 2018
8e89267
virtualfilesystem: check if directory is included
Oct 9, 2018
d4980f2
backwards-compatibility: support the post-indexchanged hook
dscho May 28, 2019
6918eec
BRANCHES.md: Add explanation of branches and using forks
Jul 27, 2018
d00c4ca
gvfs: verify that the built-in FSMonitor is disabled
dscho Jun 18, 2021
9c27a8e
status: add status serialization mechanism
jeffhostetler Aug 22, 2017
01f92dc
Teach ahead-behind and serialized status to play nicely together
jamill Jan 10, 2018
7256d4f
status: serialize to path
jeffhostetler Feb 2, 2018
22e9744
status: reject deserialize in V2 and conflicts
jeffhostetler Feb 7, 2018
af61fbc
serialize-status: serialize global and repo-local exclude file metadata
jeffhostetler Jul 20, 2018
52eb244
status: deserialization wait
jeffhostetler Jul 25, 2018
f51c96d
merge-recursive: avoid confusing logic in was_dirty()
dscho May 21, 2019
28388fb
merge-recursive: add some defensive coding to was_dirty()
dscho May 21, 2019
5f499d9
merge-recursive: teach was_dirty() about the virtualfilesystem
dscho May 21, 2019
09f8e30
status: deserialize with -uno does not print correct hint
jeffhostetler Jun 25, 2019
82ad4b7
fsmonitor: check CE_FSMONITOR_VALID in ce_uptodate
kewillford Nov 21, 2019
35e920a
gvfs:trace2:data: add trace2 tracing around read_object_process
jeffhostetler Sep 26, 2018
0e205d7
fsmonitor: add script for debugging and update script for tests
kewillford Nov 21, 2019
7d872c3
gvfs:trace2:data: status deserialization information
jeffhostetler Sep 26, 2018
991de58
status: disable deserialize when verbose output requested.
jeffhostetler Apr 11, 2020
680a5dd
gvfs:trace2:data: status serialization
jeffhostetler Jan 7, 2019
e0f79ba
t7524: add test for verbose status deserialzation
jeffhostetler Apr 11, 2020
56b57b4
gvfs:trace2:data: add vfs stats
jeffhostetler Nov 19, 2018
14452b7
deserialize-status: silently fallback if we cannot read cache file
jeffhostetler May 13, 2020
3b94725
trace2: refactor setting process starting time
jeffhostetler Apr 15, 2019
f01198a
trace2:gvfs:experiment: clear_ce_flags_1
jeffhostetler Apr 30, 2019
d5ab32c
trace2:gvfs:experiment: report_tracking
jeffhostetler Apr 30, 2019
7384393
trace2:gvfs:experiment: read_cache: annotate thread usage in read-cache
jeffhostetler Jun 14, 2019
091f2bf
trace2:gvfs:experiment: read-cache: time read/write of cache-tree ext…
jeffhostetler Jul 9, 2019
2ba30a8
trace2:gvfs:experiment: add region to apply_virtualfilesystem()
jeffhostetler Jul 16, 2019
dbe4182
trace2:gvfs:experiment: add region around unpack_trees()
jeffhostetler Jul 16, 2019
3dead05
trace2:gvfs:experiment: add region to cache_tree_fully_valid()
jeffhostetler Jul 16, 2019
d746e1d
trace2:gvfs:experiment: add unpack_entry() counter to unpack_trees() …
jeffhostetler Jul 16, 2019
fce6f11
trace2:gvfs:experiment: increase default event depth for unpack-tree …
jeffhostetler Jul 25, 2019
a617e62
credential: set trace2_child_class for credential manager children
jeffhostetler Oct 3, 2019
dcf48b2
sub-process: do not borrow cmd pointer from caller
jeffhostetler Sep 18, 2019
cbc202b
sub-process: add subprocess_start_argv()
jeffhostetler Sep 18, 2019
f872f9d
sha1-file: add function to update existing loose object cache
jeffhostetler Sep 24, 2019
434847c
packfile: add install_packed_git_and_mru()
jeffhostetler Sep 25, 2019
e460ad4
trace2:gvfs:experiment: add data for check_updates() in unpack_trees()
jeffhostetler Jul 25, 2019
b360b32
index-pack: avoid immediate object fetch while parsing packfile
jeffhostetler Sep 24, 2019
68d7101
Trace2:gvfs:experiment: capture more 'tracking' details
jeffhostetler Jul 26, 2019
5579a80
gvfs-helper: create tool to fetch objects using the GVFS Protocol
jeffhostetler Aug 13, 2019
ac4a124
sha1-file: create shared-cache directory if it doesn't exist
jeffhostetler Oct 7, 2019
6619a85
gvfs-helper: better handling of network errors
jeffhostetler Oct 8, 2019
311af31
gvfs-helper-client: properly update loose cache with fetched OID
jeffhostetler Oct 8, 2019
8c1a1c4
gvfs-helper: V2 robust retry and throttling
jeffhostetler Oct 10, 2019
43442ca
gvfs-helper: expose gvfs/objects GET and POST semantics
jeffhostetler Oct 21, 2019
0d98739
gvfs-helper: dramatically reduce progress noise
derrickstolee Oct 24, 2019
d8a4d89
gvfs-helper-client.h: define struct object_id
derrickstolee Nov 4, 2019
9175db6
gvfs-helper: handle pack-file after single POST request
derrickstolee Nov 11, 2019
f89f72b
test-gvfs-prococol, t5799: tests for gvfs-helper
jeffhostetler Oct 25, 2019
04a00fc
gvfs-helper: move result-list construction into install functions
jeffhostetler Nov 13, 2019
39a8eb2
gvfs-helper: add prefetch support
jeffhostetler Nov 11, 2019
b8d9a68
t5799: add support for POST to return either a loose object or packfile
jeffhostetler Nov 13, 2019
9242228
gvfs-helper: add prefetch .keep file for last packfile
jeffhostetler Nov 26, 2019
d661257
t5799: cleanup wc-l and grep-c lines
jeffhostetler Nov 13, 2019
7ed9e35
gvfs-helper: do one read in my_copy_fd_len_tail()
derrickstolee Dec 16, 2019
4c63e73
gvfs-helper: verify loose objects after write
derrickstolee Sep 18, 2020
4f4b450
gvfs-helper: move content-type warning for prefetch packs
derrickstolee Dec 16, 2019
d765e39
t7599: create corrupt blob test
jeffhostetler Sep 18, 2020
3c4c219
fetch: use gvfs-helper prefetch under config
derrickstolee Dec 17, 2019
ae0eb9a
gvfs-helper: better support for concurrent packfile fetches
jeffhostetler Dec 18, 2019
2b1e1c1
remote-curl: do not call fetch-pack when using gvfs-helper
derrickstolee Feb 3, 2020
e7f9082
fetch: reprepare packs before checking connectivity
derrickstolee Mar 12, 2020
2edc14c
gvfs-helper: add --max-retries to prefetch verb
jeffhostetler Apr 12, 2023
21f9a98
gvfs-helper: retry when creating temp files
derrickstolee Dec 26, 2019
38ff92e
t5799: add tests to detect corrupt pack/idx files in prefetch
jeffhostetler Apr 13, 2023
98386f1
sparse: avoid warnings about known cURL issues in gvfs-helper.c
derrickstolee Aug 3, 2021
6086795
homebrew: add GitHub workflow to release Cask
mjcheetham Jul 24, 2020
5a63114
gvfs-helper: ignore .idx files in prefetch multi-part responses
jeffhostetler Apr 13, 2023
9ee1e4a
upload-pack: fix race condition in error messages
derrickstolee Aug 27, 2019
273466d
maintenance: care about gvfs.sharedCache config
derrickstolee Dec 15, 2020
cae5026
unpack-trees:virtualfilesystem: Improve efficiency of clear_ce_flags
neerajsi-msft2 Feb 6, 2021
ecd2e75
Adding winget workflows
Apr 29, 2021
cfed047
release: create initial Windows installer build workflow
vdye Jul 16, 2021
7563c50
release: add Mac OSX installer build
vdye Jul 16, 2021
6dc4e87
release: build unsigned Ubuntu .deb package
vdye Jul 16, 2021
3869825
Disable the `monitor-components` workflow in msft-git
dscho May 13, 2022
2b9e0f6
release: add signing step for .deb package
vdye Jul 16, 2021
44ef83b
.github: enable windows builds on microsoft fork
derrickstolee Mar 8, 2023
166decd
Makefile: allow specifying GIT_BUILT_FROM_COMMIT
vdye Nov 30, 2021
fea717b
dist: archive HEAD instead of HEAD^{tree}
vdye Dec 2, 2021
be41ec0
update-microsoft-git: create barebones builtin
derrickstolee Apr 29, 2021
644384f
release: create draft GitHub release with packages & installers
vdye Jul 16, 2021
3eb9a0a
release: include GIT_BUILT_FROM_COMMIT in MacOS build
vdye Dec 2, 2021
8ba7557
update-microsoft-git: Windows implementation
derrickstolee Apr 29, 2021
b373c23
release: continue pestering until user upgrades
derrickstolee Oct 6, 2021
fae3436
release: add installer validation
ldennington Aug 17, 2022
82e9672
.github: update ISSUE_TEMPLATE.md for microsoft/git
derrickstolee Mar 16, 2022
8c64722
.github: update PULL_REQUEST_TEMPLATE.md
derrickstolee Mar 16, 2022
747ad2c
git_config_set_multivar_in_file_gently(): add a lock timeout
dscho May 18, 2021
ddba2fa
update-microsoft-git: use brew on macOS
derrickstolee Apr 29, 2021
b54bd15
Adjust README.md for microsoft/git
May 4, 2021
6682f12
scalar: set the config write-lock timeout to 150ms
dscho May 18, 2021
ae4a077
scalar: add docs from microsoft/scalar
derrickstolee Jun 16, 2021
8ccb9c1
Merge branch 'scalar-gentler-config-locking'
dscho May 19, 2021
43a5337
Merge branch 'scalar-extra-docs'
dscho Nov 16, 2021
1498a83
scalar (Windows): use forward slashes as directory separators
dscho May 10, 2022
d98431c
scalar: add retry logic to run_git()
derrickstolee Jun 17, 2021
5ed4466
scalar: support the `config` command for backwards compatibility
dscho May 27, 2021
a69f8a0
Merge branch 'microsoft/vfs-2.35.0'
dscho Oct 7, 2021
d4b2133
scalar: implement a minimal JSON parser
dscho Apr 26, 2021
e7c0563
scalar clone: support GVFS-enabled remote repositories
dscho Aug 24, 2021
11adbf7
test-gvfs-protocol: also serve smart protocol
dscho Apr 16, 2021
b98dacc
gvfs-helper: add the `endpoint` command
dscho Apr 26, 2021
1a61a8e
dir_inside_of(): handle directory separators correctly
dscho May 14, 2021
fb255f0
Merge branch 'scalar'
dscho Aug 24, 2021
85d9478
scalar: disable authentication in unattended mode
dscho May 6, 2021
c9c7b34
sparse-checkout: add config to disable deleting dirs
derrickstolee Aug 22, 2021
bedddbb
add/rm: allow adding sparse entries when virtual
derrickstolee Jun 29, 2021
45e72a7
diff: ignore sparse paths in diffstat
derrickstolee Jul 26, 2021
3de4449
Merge pull request #392: add: allow adding sparse entries when virtual
derrickstolee Jul 1, 2021
4cad8ac
Merge branch 'sparse-index/merge' into vfs-2.33.0
derrickstolee Aug 24, 2021
b584ffd
repo-settings: enable sparse index by default
derrickstolee Jun 15, 2021
eae77a5
Merge pull request #410: Sparse Index: latest integrations
derrickstolee Aug 24, 2021
41b507a
diff(sparse-index): verify with partially-sparse
ldennington Sep 10, 2021
ba55e8d
Merge pull request #414: Make sparse index the default
derrickstolee Aug 26, 2021
203919c
Merge pull request #419 from ldennington/sparse-index-diff
ldennington Sep 12, 2021
9e01926
stash: expand testing for `git stash -u`
vdye Sep 22, 2021
d99a8a0
sequencer: avoid progress when stderr is redirected
derrickstolee Sep 23, 2021
1da34b2
Merge pull request #430 from vdye/sparse-index/clean
vdye Sep 23, 2021
71138e2
Merge pull request #432: sequencer: avoid progress when stderr is red…
derrickstolee Sep 23, 2021
30b36a6
sparse: add vfs-specific precautions
derrickstolee Oct 31, 2021
cb839fe
Merge core VFS features
dscho Jun 11, 2018
ab37eac
Merge advanced VFS-specific features
dscho Jun 11, 2018
498a997
Merge virtualfilesystem hook
dscho Jun 11, 2018
d5908c1
Merge updates to serialized status
dscho Jun 11, 2018
740600d
Merge trace2 experimental regions
jeffhostetler Apr 23, 2019
f60db9a
Merge first wave of gvfs-helper feature
jeffhostetler Nov 14, 2019
b1d2c0f
Merge gvfs-helper prefetch feature
derrickstolee Dec 17, 2019
69f2af6
Harden gvfs-helper to validate the packfiles in a multipart prefetch …
jeffhostetler Apr 17, 2023
97a2f31
Merge upstreamable patches
dscho Oct 18, 2018
784cfcf
Merge pull request #301: Update 'git maintenance' to match upstream
derrickstolee Dec 15, 2020
e4a2af6
Merge pull request #315: unpack-trees:virtualfilesystem: Improve effi…
derrickstolee Feb 16, 2021
a94cf79
Merge branch 'add-workflows'
derrickstolee Apr 30, 2021
5f0261b
Merge branch 'adjust-g4w-workflows'
dscho May 13, 2022
db534bb
Merge pull request #399 from vdye/feature/build-installers
vdye Jul 29, 2021
603d78e
Merge pull request #472 from vdye/ms/macos-build-options
vdye Dec 6, 2021
9945961
Merge pull request #329: Add `git update-microsoft-git`
derrickstolee Apr 30, 2021
7443907
Merge pull request #333: update microsoft/git README
derrickstolee May 17, 2021
a39b9ec
scalar: do initialize `gvfs.sharedCache`
dscho May 3, 2021
d1ba0f9
scalar diagnose: include shared cache info
dscho Jun 1, 2021
965a390
scalar: only try GVFS protocol on https:// URLs
dscho Apr 28, 2021
0bb7fae
reset: fix mixed reset when using virtual filesystem
Mar 15, 2017
aaa7d52
Merge pull request #494: reset: fix mixed reset when using virtual fi…
derrickstolee Apr 4, 2022
ad14a2e
scalar: verify that we can use a GVFS-enabled repository
dscho Apr 16, 2021
7378a39
scalar: add the `cache-server` command
dscho Apr 23, 2021
25aa160
scalar: add a test toggle to skip accessing the vsts/info endpoint
dscho May 12, 2021
84ce512
scalar: adjust documentation to the microsoft/git fork
dscho Jan 25, 2022
f905638
scalar: enable untracked cache unconditionally
derrickstolee Jun 21, 2021
7efae3f
scalar diagnose: accommodate Scalar's Functional Tests
dscho May 9, 2022
ad15733
scalar: parse `clone --no-fetch-commits-and-trees` for backwards comp…
dscho Aug 24, 2021
0ca292a
ci: run Scalar's Functional Tests
dscho Jun 8, 2021
c0617ee
Merge branch 'scalar-with-gvfs'
dscho May 3, 2021
5aeee2f
abspath: make strip_last_path_component() global
derrickstolee Oct 4, 2022
cfa61bd
setup: add discover_git_directory_reason()
derrickstolee May 24, 2022
779915c
scalar: upgrade to newest FSMonitor config setting
vdye Apr 5, 2022
8468f62
Merge branch 'run-scalar-functional-tests'
dscho Nov 16, 2021
6ccab79
scalar: .scalarCache should live above enlistment
derrickstolee Sep 30, 2022
45ea335
scalar reconfigure: help users remove buggy repos
derrickstolee May 23, 2022
f9997c4
Merge branch 'scalar-reconfigure'
dscho Jun 1, 2021
679f0de
scalar: add --no-src option
derrickstolee Sep 30, 2022
003438d
maintenance: add get_random_minute()
derrickstolee Aug 4, 2023
a0bfea8
maintenance: use random minute in launchctl scheduler
derrickstolee Aug 4, 2023
b6aec3e
maintenance: use random minute in Windows scheduler
derrickstolee Aug 4, 2023
5ef6e38
maintenance: use random minute in cron scheduler
derrickstolee Aug 4, 2023
c66dfb2
maintenance: swap method locations
derrickstolee Aug 7, 2023
81cdda3
Merge pull request #508: scalar reconfigure: help users remove buggy …
derrickstolee May 31, 2022
cf2cb00
maintenance: use random minute in systemd scheduler
derrickstolee Aug 4, 2023
c364ac0
Merge pull request #536: Allow --no-src during clones and git worktre…
dscho Oct 4, 2022
3bf089b
maintenance: fix systemd schedule overlaps
derrickstolee Aug 8, 2023
80631e0
Merge pull request #371 from dscho/run-scalar-functional-tests-and-fi…
dscho Jun 9, 2021
6d15915
maintenance: update schedule before config
derrickstolee Aug 9, 2023
a309546
Merge branch 'sparse-index-stuff'
dscho Jun 17, 2022
c3a3d55
maintenance: use random minute for scheduling (#597)
derrickstolee Aug 14, 2023
22acd55
credential: add new interactive config option
derrickstolee Aug 22, 2023
384c80e
maintenance: add custom config to background jobs
derrickstolee Aug 16, 2023
c68e5fb
scalar: configure maintenance during 'reconfigure'
derrickstolee Aug 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions name-hash.c
Original file line number Diff line number Diff line change
@@ -736,6 +736,26 @@ struct cache_entry *index_file_exists(struct index_state *istate, const char *na
return NULL;
}

struct cache_entry *index_file_next_match(struct index_state *istate, struct cache_entry *ce, int igncase)
{
struct cache_entry *next;

if (!igncase || !ce) {
return NULL;
}

next = hashmap_get_next_entry(&istate->name_hash, ce, ent);
if (!next)
return NULL;

hashmap_for_each_entry_from(&istate->name_hash, next, ent) {
if (same_name(next, ce->name, ce_namelen(ce), igncase))
return next;
}

return NULL;
}

void free_name_hash(struct index_state *istate)
{
if (!istate->name_hash_initialized)
1 change: 1 addition & 0 deletions name-hash.h
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ struct index_state;
int index_dir_exists(struct index_state *istate, const char *name, int namelen);
void adjust_dirname_case(struct index_state *istate, char *name);
struct cache_entry *index_file_exists(struct index_state *istate, const char *name, int namelen, int igncase);
struct cache_entry *index_file_next_match(struct index_state *istate, struct cache_entry *ce, int igncase);

int test_lazy_init_name_hash(struct index_state *istate, int try_threaded);
void add_name_hash(struct index_state *istate, struct cache_entry *ce);
27 changes: 13 additions & 14 deletions unpack-trees.c
Original file line number Diff line number Diff line change
@@ -1711,14 +1711,6 @@ static int clear_ce_flags_1(struct index_state *istate,
continue;
}

/* if it's not in the virtual file system, exit early */
if (core_virtualfilesystem) {
if (is_included_in_virtualfilesystem(ce->name, ce->ce_namelen) > 0)
ce->ce_flags &= ~clear_mask;
cache++;
continue;
}

if (prefix->len && strncmp(ce->name, prefix->buf, prefix->len))
break;

@@ -1795,12 +1787,19 @@ static int clear_ce_flags(struct index_state *istate,
xsnprintf(label, sizeof(label), "clear_ce_flags/0x%08lx_0x%08lx",
(unsigned long)select_mask, (unsigned long)clear_mask);
trace2_region_enter("unpack_trees", label, the_repository);
rval = clear_ce_flags_1(istate,
istate->cache,
istate->cache_nr,
&prefix,
select_mask, clear_mask,
pl, 0, 0);
if (core_virtualfilesystem) {
rval = clear_ce_flags_virtualfilesystem(istate,
select_mask,
clear_mask);
} else {
rval = clear_ce_flags_1(istate,
istate->cache,
istate->cache_nr,
&prefix,
select_mask, clear_mask,
pl, 0, 0);
}

trace2_region_leave("unpack_trees", label, the_repository);

stop_progress(&istate->progress);
142 changes: 91 additions & 51 deletions virtualfilesystem.c
Original file line number Diff line number Diff line change
@@ -252,93 +252,133 @@ int is_excluded_from_virtualfilesystem(const char *pathname, int pathlen, int dt
return -1;
}

/*
* Update the CE_SKIP_WORKTREE bits based on the virtual file system.
*/
void apply_virtualfilesystem(struct index_state *istate)
struct apply_virtual_filesystem_stats {
int nr_unknown;
int nr_vfs_dirs;
int nr_vfs_rows;
int nr_bulk_skip;
int nr_explicit_skip;
};

static void clear_ce_flags_virtualfilesystem_1(struct index_state *istate, int select_mask, int clear_mask,
struct apply_virtual_filesystem_stats *stats)
{
char *buf, *entry;
int i;
int nr_unknown = 0;
int nr_vfs_dirs = 0;
int nr_vfs_rows = 0;
int nr_bulk_skip = 0;
int nr_explicit_skip = 0;

if (!git_config_get_virtualfilesystem())
return;

trace2_region_enter("vfs", "apply", the_repository);

if (!virtual_filesystem_data.len)
get_virtual_filesystem_data(&virtual_filesystem_data);

/* set CE_SKIP_WORKTREE bit on all entries */
for (i = 0; i < istate->cache_nr; i++)
istate->cache[i]->ce_flags |= CE_SKIP_WORKTREE;

/* clear CE_SKIP_WORKTREE bit for everything in the virtual file system */
/* clear specified flag bits for everything in the virtual file system */
entry = buf = virtual_filesystem_data.buf;
for (i = 0; i < virtual_filesystem_data.len; i++) {
if (buf[i] == '\0') {
struct cache_entry *ce;
int pos, len;

nr_vfs_rows++;
stats->nr_vfs_rows++;

len = buf + i - entry;

/* look for a directory wild card (ie "dir1/") */
if (buf[i - 1] == '/') {
nr_vfs_dirs++;
stats->nr_vfs_dirs++;
if (ignore_case)
adjust_dirname_case(istate, entry);
pos = index_name_pos(istate, entry, len);
if (pos < 0) {
pos = -pos - 1;
while (pos < istate->cache_nr && !fspathncmp(istate->cache[pos]->name, entry, len)) {
if (istate->cache[pos]->ce_flags & CE_SKIP_WORKTREE)
nr_bulk_skip++;
istate->cache[pos]->ce_flags &= ~CE_SKIP_WORKTREE;
pos++;
for (pos = -pos - 1; pos < istate->cache_nr; pos++) {
ce = istate->cache[pos];
if (fspathncmp(ce->name, entry, len))
break;

if (select_mask && !(ce->ce_flags & select_mask))
continue;

if (ce->ce_flags & clear_mask)
stats->nr_bulk_skip++;
ce->ce_flags &= ~clear_mask;
}
}
} else {
if (ignore_case) {
struct cache_entry *ce = index_file_exists(istate, entry, len, ignore_case);
if (ce) {
if (ce->ce_flags & CE_SKIP_WORKTREE)
nr_explicit_skip++;
ce->ce_flags &= ~CE_SKIP_WORKTREE;
}
else {
nr_unknown++;
}
ce = index_file_exists(istate, entry, len, ignore_case);
} else {
int pos = index_name_pos(istate, entry, len);
if (pos >= 0) {
if (istate->cache[pos]->ce_flags & CE_SKIP_WORKTREE)
nr_explicit_skip++;
istate->cache[pos]->ce_flags &= ~CE_SKIP_WORKTREE;
}
else {
nr_unknown++;
}

ce = NULL;
if (pos >= 0)
ce = istate->cache[pos];
}

if (ce) {
do {
if (!select_mask || (ce->ce_flags & select_mask)) {
if (ce->ce_flags & clear_mask)
stats->nr_explicit_skip++;
ce->ce_flags &= ~clear_mask;
}

/*
* There may be aliases with different cases of the same
* name that also need to be modified.
*/
if (ignore_case)
ce = index_file_next_match(istate, ce, ignore_case);
else
break;

} while (ce);
} else {
stats->nr_unknown++;
}
}

entry += len + 1;
}
}
}

/*
* Clear the specified flags for all entries in the virtual file system
* that match the specified select mask. Returns the number of entries
* processed.
*/
int clear_ce_flags_virtualfilesystem(struct index_state *istate, int select_mask, int clear_mask)
{
struct apply_virtual_filesystem_stats stats = {0};

clear_ce_flags_virtualfilesystem_1(istate, select_mask, clear_mask, &stats);
return istate->cache_nr;
}

/*
* Update the CE_SKIP_WORKTREE bits based on the virtual file system.
*/
void apply_virtualfilesystem(struct index_state *istate)
{
int i;
struct apply_virtual_filesystem_stats stats = {0};

if (!git_config_get_virtualfilesystem())
return;

trace2_region_enter("vfs", "apply", the_repository);

/* set CE_SKIP_WORKTREE bit on all entries */
for (i = 0; i < istate->cache_nr; i++)
istate->cache[i]->ce_flags |= CE_SKIP_WORKTREE;

if (nr_vfs_rows > 0) {
trace2_data_intmax("vfs", the_repository, "apply/tracked", nr_bulk_skip + nr_explicit_skip);
clear_ce_flags_virtualfilesystem_1(istate, 0, CE_SKIP_WORKTREE, &stats);
if (stats.nr_vfs_rows > 0) {
trace2_data_intmax("vfs", the_repository, "apply/tracked", stats.nr_bulk_skip + stats.nr_explicit_skip);

trace2_data_intmax("vfs", the_repository, "apply/vfs_rows", nr_vfs_rows);
trace2_data_intmax("vfs", the_repository, "apply/vfs_dirs", nr_vfs_dirs);
trace2_data_intmax("vfs", the_repository, "apply/vfs_rows", stats.nr_vfs_rows);
trace2_data_intmax("vfs", the_repository, "apply/vfs_dirs", stats.nr_vfs_dirs);

trace2_data_intmax("vfs", the_repository, "apply/nr_unknown", nr_unknown);
trace2_data_intmax("vfs", the_repository, "apply/nr_bulk_skip", nr_bulk_skip);
trace2_data_intmax("vfs", the_repository, "apply/nr_explicit_skip", nr_explicit_skip);
trace2_data_intmax("vfs", the_repository, "apply/nr_unknown", stats.nr_unknown);
trace2_data_intmax("vfs", the_repository, "apply/nr_bulk_skip", stats.nr_bulk_skip);
trace2_data_intmax("vfs", the_repository, "apply/nr_explicit_skip", stats.nr_explicit_skip);
}

trace2_region_leave("vfs", "apply", the_repository);
7 changes: 7 additions & 0 deletions virtualfilesystem.h
Original file line number Diff line number Diff line change
@@ -6,6 +6,13 @@
*/
void apply_virtualfilesystem(struct index_state *istate);

/*
* Clear the specified flags for all entries in the virtual file system
* that match the specified select mask. Returns the number of entries
* processed.
*/
int clear_ce_flags_virtualfilesystem(struct index_state *istate, int select_mask, int clear_mask);

/*
* Return 1 if the requested item is found in the virtual file system,
* 0 for not found and -1 for undecided.