Download commit pack even when commit exists as loose object#1995
Open
tyrielv wants to merge 1 commit into
Open
Download commit pack even when commit exists as loose object#1995tyrielv wants to merge 1 commit into
tyrielv wants to merge 1 commit into
Conversation
When TryDownloadCommit finds the commit via CommitAndRootTreeExists, it now checks whether the commit is a loose object. Loose commits (e.g., from a prior 'git show' or 'git log' in a mounted enlistment) do not include reachable trees. Skipping the download in this case causes 'git checkout -f' to fail with 'unable to read tree', followed by an expensive fallback that re-downloads and retries checkout. If the commit is in a pack file (prefetch or commit pack), trees are included by the GVFS protocol, so the download can safely be skipped. Added GitRepo.LooseObjectExists() to check whether a SHA exists as a loose object file in the shared cache or local object store. Assisted-by: Claude Opus 4.6 Signed-off-by: Tyrie Vella <tyrielv@gmail.com>
474a50d to
1784125
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the worst-case clone performance when a commit exists as a loose object in the shared cache (e.g., from a prior
git showorgit login a mounted enlistment).Before:
TryDownloadCommitchecksCommitAndRootTreeExists- if the commit and root tree exist (even as loose objects), the commit+trees pack download is skipped.git checkout -fthen fails withunable to read treebecause subtrees are missing, triggering an expensive fallback: re-download the pack + retry checkout. On a large repo this wastes ~60 seconds.After:
TryDownloadCommitadditionally checks whether the commit is a loose object via the newGitRepo.LooseObjectExists()method. If the commit is loose, the pack is downloaded proactively. If the commit is in a pack file, trees are included by the GVFS protocol, so the download is safely skipped.Changes
CommitAndRootTreeExistsreturns true, checkLooseObjectExistsbefore skipping downloadLooseObjectExistsmethod - fast filesystem check for loose object filesPerformance Impact (large repo)