feat(source): follow the remote default branch when no ref is pinned#45
Merged
Conversation
A git source with no branch/tag/rev resolved to a hardcoded `main`, so a
repository whose default branch is `master` or `trunk` failed to resolve and
forced an explicit `branch =`. Resolution now defers to the repository's own
default branch.
- add `Refspec::Default` for the no-ref case; `refspec()`/`intrinsic_refspec()`
return it instead of `Branch("main")`
- resolve it by peeling the bare mirror's HEAD, which gix sets from the remote's
advertised default at clone; incremental fetches advance that branch's ref, so
HEAD always lands on the current tip
- encode as a stable `default` discriminator (network-independent), so the lock
stays reproducible and `encode_ref`/`Display` round-trip without a branch name
Known edge: HEAD is written once at clone and not refreshed if upstream renames
its default branch; the pinned commit is unaffected and a re-clone of the
disposable cache picks up the rename.
README documents the user-facing default; the GUIDE.md walkthrough for this
change rides with the docs branch (GUIDE.md does not exist on main).
srnnkls
force-pushed
the
feat/default-branch-resolution
branch
from
June 24, 2026 21:22
3ef1449 to
347ffc3
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.
What
A git source with no
branch/tag/revresolved to a hardcodedmain. A repository whose default branch ismasterortrunkfailed to resolve and forced an explicitbranch =. Resolution now defers to the repository's own default branch.How
Refspec::Defaultfor the no-ref case;refspec()/intrinsic_refspec()return it instead ofBranch("main").HEAD, which gix sets from the remote's advertised default at clone. Incremental fetches advance that branch's ref, so peelingHEADalways lands on the current tip.defaultdiscriminator (network-independent), so the lock stays reproducible andencode_ref/Displayround-trip without a branch name. A no-ref source recordsresolved = "default"with no ref discriminator.Behavior
master/trunk/mainrepos all just work with no config.phora updatere-resolves the default branch to its current tip, exactly as it would track an explicitbranch.updatere-resolves.Known edge
HEADis written once at clone and not refreshed if upstream renames its default branch — the stale symref resolves to the old branch until the disposable cache is re-cloned. The locked commit is unaffected. Pin an explicitbranchto track a rename without a re-clone. Upgrade path: capture theHEADsymref from the fetch handshake and rewrite mirrorHEADeach fetch.Tests
resolve_default_follows_remote_default_branch_when_not_main— atrunk-default repo (nomain) resolves viaDefault.resolve_default_survives_an_incremental_fetch— tracks the tip across an incremental fetch.maindefault.mainbase after rebase: 1267 lib + all integration binaries + 7 scrut suites + clippy (pedantic,-D warnings) + rustfmt.Docs
README documents the user-facing default. The GUIDE.md walkthrough for this change lands with the docs branch (#11) —
GUIDE.mddoes not exist onmain, so it cannot ride in this PR.