Skip to content

Read alternate object stores when opening a repository#194

Merged
andrew merged 1 commit into
mainfrom
alternates-fs
May 9, 2026
Merged

Read alternate object stores when opening a repository#194
andrew merged 1 commit into
mainfrom
alternates-fs

Conversation

@andrew
Copy link
Copy Markdown
Contributor

@andrew andrew commented May 7, 2026

go-git's PlainOpen chroots its billy filesystem to .git, so absolute paths in objects/info/alternates can't be followed and borrowed objects are invisible. In a repo created with git clone --shared or --reference, any SHA in the borrowed history fails with reference not found while HEAD (a local object) works. That matches the report in #166.

PlainOpenOptions doesn't expose AlternatesFS, so after discovery we rebuild the storage with filesystem.Options{AlternatesFS: osfs.New(<volume root>)} and reopen. If the storer isn't a *filesystem.Storage or the reopen fails we keep the original repo, so this is strictly additive.

Abbreviated SHAs that live only in the alternate still fail because go-git's resolveHashPrefix doesn't traverse alternates; #193 covers that via the git rev-parse fallback. The two together handle everything in the #166 report.

The repro matrix that pinned this down is at /tmp/repro-resolve locally if anyone wants it; not committing it since it's a throwaway.

go-git's PlainOpen chroots its billy filesystem to .git, so absolute
paths in objects/info/alternates can't be followed and borrowed
objects are invisible. Repos created with clone --shared or
--reference would fail to resolve any SHA in the borrowed history
with "reference not found".

Reopen the storage with AlternatesFS rooted at the volume root so
go-git can follow alternates. PlainOpenOptions doesn't expose this
so the storage has to be rebuilt by hand after discovery.

Reported in #166.
@andrew andrew merged commit 08425d3 into main May 9, 2026
7 checks passed
@andrew andrew deleted the alternates-fs branch May 9, 2026 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant