storage: filesystem, Search alternates in HashesWithPrefix#2087
Merged
Conversation
EncodedObject, HasEncodedObject and EncodedObjectSize all fall back to alternate object stores, but HashesWithPrefix only consults local loose objects and packs. With alternates configured, ResolveRevision on an abbreviated hash that lives in the alternate returns ErrReferenceNotFound even though the full hash resolves. Iterate alternates after local lookup, deduplicating against results already collected. Also mark pack hits as seen so a hash present in multiple packs or in both a pack and an alternate is returned once. Signed-off-by: Andrew Nesbitt <[email protected]>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates storage/filesystem.ObjectStorage.HashesWithPrefix to consult alternate object stores (matching the fallback behavior of other object-lookup APIs) and to deduplicate results so the same object hash is returned only once. This fixes cases where abbreviated hash resolution fails when the object exists only in an alternate.
Changes:
- Mark packfile matches as “seen” to prevent duplicate hashes when the same object appears in multiple packs.
- After local loose/pack lookup, iterate configured alternates and merge/deduplicate their
HashesWithPrefixresults. - Add a filesystem storage test covering
HashesWithPrefixresolution via alternates.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| storage/filesystem/object.go | Extend HashesWithPrefix to dedupe pack hits and consult alternates. |
| storage/filesystem/object_test.go | Add regression test ensuring HashesWithPrefix finds objects stored in alternates. |
The pack entry iterator was only closed after a full iteration; an error from Next() returned early without closing it. Signed-off-by: Andrew Nesbitt <[email protected]>
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.
EncodedObject,HasEncodedObjectandEncodedObjectSizeall fall back to alternate object stores, butHashesWithPrefixonly consults local loose objects and packs. With alternates configured,ResolveRevisionon an abbreviated hash that lives in the alternate returnsErrReferenceNotFoundeven though the full hash resolves.This iterates alternates after local lookup, deduplicating against results already collected. It also marks pack hits as seen so a hash present in multiple packs or in both a pack and an alternate is returned once.