Repository navigation
Conversation
| repo.prepare_lfs_config(revision)?; | ||
| configure_git_network(&mut cmd, url, disable_ssl, offline); |
There was a problem hiding this comment.
[P2] Enforce offline mode for the selected LFS endpoint
Loading .lfsconfig can now select an HTTP endpoint even when the Git source uses file://. configure_git_network only sets GIT_ALLOW_PROTOCOL=file, which Git LFS's HTTP client does not honor. In an isolated reproduction, the base commands made no HTTP requests, while the new commands posted to /objects/batch with that restriction set. Consequently, uv lock --offline can access the network for this input. Enforce offline policy against the resolved LFS endpoint before fetching, while allowing local database copies.
| pub(crate) fn contains_lfs_artifacts(&self, oid: GitOid) -> bool { | ||
| self.repo.lfs_fsck_objects(&format!("{oid}^0")) | ||
| self.repo.lfs_fsck_objects(&format!("{oid}^0")) == LfsValidation::Passed |
There was a problem hiding this comment.
[P2] Load the selected revision's configuration before cache validation
prepare_lfs_config now leaves revision-specific configuration in the shared database, but this cache-hit check runs before updating it. After fetching a revision with lfs.fetchexclude = module.py, requesting another cached commit without that exclusion still validates using the previous exclusion. I reproduced fsck succeeding with the required object absent, then failing after removing the stale configuration. GitSource::fetch consequently skips the remote fetch, and checkout recovery fails against the incomplete database. Prepare the requested revision's configuration before this validation, treating preparation failures as cache misses.
Merging this PR will improve performance by 13.75%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ⚡ |
Simulation | discover_workspace_from_all_members_with_excludes |
162.6 ms | 140.5 ms | +15.74% |
| ⚡ | WallTime | git_fetch_warm_reference[django] |
12.1 ms | 10.6 ms | +14.29% |
| ⚡ | WallTime | git_fetch_warm_reference[flask] |
12 ms | 10.6 ms | +13.18% |
| ⚡ | WallTime | git_fetch_warm_reference[sampleproject] |
7.5 ms | 6.7 ms | +11.85% |
Tip
Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.
Comparing zb/fix-git-lfs-cache-recovery (38357d1) with zb/preview-git-partial-fetches (2bda788)2
Footnotes
-
35 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
-
No successful run was found on
zb/preview-git-partial-fetches(25072c4) during the generation of this report, so 66d95ad was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩
| if !local_endpoint { | ||
| return Err(GitError::TransportNotAllowed.into()); |
There was a problem hiding this comment.
[P2] Check cached LFS objects before rejecting the offline endpoint
For a file:// source selected by branch or tag, GitSource::fetch bypasses the precise-commit cache shortcut, and GitRemote::checkout calls this even when all required LFS objects are cached. An HTTP endpoint in .lfsconfig now makes --offline fail despite needing no downloads. In an isolated Git LFS probe, both fsck --objects and fetch origin <revision> succeeded in this state with zero HTTP requests. After preparing the revision’s configuration, allow LfsValidation::Passed to return success before rejecting a nonlocal endpoint; keep Skipped on the fetch-required path.
| Command::new("git") | ||
| .args(["lfs", "fsck", "--objects", &revision]) | ||
| .current_dir(db_root.path()) | ||
| .output()? |
There was a problem hiding this comment.
[P3] Verify checkout objects in the old-LFS recovery test
This case removes LFS objects from both the database and checkout, but only verifies the database afterward. Consequently, incorrectly treating Skipped as cache-ready in GitDatabase::copy_to remains undetected: module.py is already materialized, and an isolated probe confirmed that git lfs checkout succeeds with its cached object missing. Also run the unshimmed git lfs fsck --objects in checkout_root after recovery so the test protects the new forced-copy behavior.
|
|
||
| /// Revision-local LFS endpoints apply to downloads, while cached-object copies stay local. | ||
| #[test] | ||
| #[cfg(all(feature = "test-git-lfs", feature = "test-pypi"))] |
There was a problem hiding this comment.
[P3] Remove the unnecessary PyPI gate from the local LFS test
This test uses local repositories and runs every lock command with --offline; unlike the neighboring compatibility tests, it never downloads an older uv from PyPI. Requiring test-pypi unnecessarily excludes the endpoint, cache-recovery, and old-LFS regression coverage when running with only test-git-lfs enabled. Gate it solely on test-git-lfs, as the preceding offline-endpoint test does.
babb44f to
7868bb5
Compare
| #[cfg(unix)] | ||
| { | ||
| // Older Git LFS cannot validate cached objects, so it must attempt a fetch. | ||
| fs_err::rename(unavailable_endpoint.path(), endpoint.path())?; | ||
| clear_source_metadata()?; | ||
| fs_err::remove_dir_all(db_root.child(".git/lfs/objects"))?; | ||
| fs_err::remove_dir_all(checkout_root.child(".git/lfs/objects"))?; |
There was a problem hiding this comment.
[P3] Give old-LFS recovery its own named test
The unsupported-fsck --objects scenario is independent of the endpoint switching and stale-exclusion scenarios above, but it only runs after they all succeed and must undo their endpoint rename before starting. This couples unrelated regression fixtures and prevents selecting the old-LFS case independently with nextest. Move this block into a separately named, Unix-gated integration test with explicit cache setup and a command snapshot.
| let lock = || { | ||
| let mut command = context.lock(); | ||
| command.args(["--offline", "--preview-features", "git-partial-fetches"]); | ||
| command | ||
| }; |
There was a problem hiding this comment.
[P3] Keep endpoint-recovery commands explicit and snapshotted
The endpoint and stale-configuration recovery steps below use lock().assert().success(), hiding their defining offline/partial-fetch arguments and leaving command output unchecked. The preceding add_git_lfs_offline_http_endpoint test demonstrates the repository’s preferred explicit uv_snapshot! pattern. Inline these context.lock() invocations with their arguments and separate snapshots, retaining the object-content assertions, so each recovery step shows its inputs and checks its diagnostics.
7868bb5 to
ff46f09
Compare
ff46f09 to
fb81ee0
Compare
fb81ee0 to
f24ca22
Compare
f24ca22 to
66cede2
Compare
66cede2 to
38357d1
Compare
38357d1 to
d16076f
Compare
Git LFS fetches in the shared database can ignore the selected revision's
.lfsconfig, and checkout recovery can follow a configured remote endpoint instead of copying local objects. Load the revision's configuration before fetching and force local copies to use the database endpoint. An unsupportedgit lfs fsck --objectsnow triggers a fetch instead of treating missing objects as cached.