Repository navigation
gitindex: list tree files with git ls-tree - #1302
Closed
keegancsmith wants to merge 2 commits into
Closed
keegancsmith wants to merge 2 commits into
keegancsmith wants to merge 2 commits into
Conversation
This moves the normal build's tree walk off go-git, one step towards dropping it from gitindex. git ls-tree -r lists the files, and the entries go through the same handleEntry as before. ls-tree fails when a tree object is missing, while the go-git walk skips that subtree (#1218). The entries are collected before any are handled, so on failure CollectFiles walks the tree with go-git instead and keeps the skip. ZOEKT_DISABLE_CATFILE_BATCH=true always uses the go-git walk. go-git also rejected names with control characters, which then got indexed under an empty name; ls-tree reports their real path. Amp-Thread-ID: https://ampcode.com/threads/T-5b43e219-dc7b-4c53-85b0-8889c69ac42b Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-5b43e219-dc7b-4c53-85b0-8889c69ac42b Co-authored-by: Amp <amp@ampcode.com>
Member
Author
|
Closing: roughly time-neutral and keeps the go-git walk as a fallback, so it adds a second implementation without removing anything. Revisit if go-git is removed once ZOEKT_DISABLE_CATFILE_BATCH is retired. |
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.
Stacked on #1301 (and #1300), and shares its
ls-treeparsing.This moves the normal build's tree walk in
RepoWalker.CollectFilesfrom go-git'sTreeWalkertogit ls-tree -r -z, as a step towards dropping go-git from gitindex rather than for speed. The entries go through the samehandleEntryas before, so submodules, the ignore file and branch bookkeeping are unchanged, andZOEKT_DISABLE_CATFILE_BATCH=truekeeps the go-git walk.ls-treefails when a tree object is missing, while the go-git walk skips that subtree and keeps going (#1218). The listing is collected before any entry is handled, so when it failsCollectFileslogs it and walks the tree with go-git instead, keeping the skip (and the error for an unreadable.sourcegraphtree).GIT_NO_LAZY_FETCH=1stops git from fetching a missing tree from a promisor remote first.TestIndexGitRepo_MissingTreedeletes a tree object and checks both modes index the rest.One behavior difference: go-git's walker rejects entry names with control characters or
.git-like components (pathutil.ValidTreePath). A file with a tab in its name was indexed under an empty name (checked), and by the same code path the contents of such a directory are not walked.ls-treereports the real paths, so these are now indexed under their names.Benchmark of
CollectFileson kubernetes HEAD (32,100 files), Go side only, 5 runs each on a 2 vCPU orb:So it's roughly time-neutral with less than half the allocations. The fresh runs are dominated by go-git opening the repository (about 300 ms and 130 MB here, loading pack indexes), which only goes away once nothing in gitindex opens a
*git.Repositoryanymore.