Honor requested branch namespaces when short names overlap
perfloop-oss/zoekt · Identity Collision
https://perfloop.ai/t/oss/case_m1y7689aw5
Verdict
VERIFIED · settled 2026-11-10 · pull request opened as sourcegraph/zoekt#1233
What happened: The check fails before this change and passes with it.
Hypothesis
Indexing a requested remote branch can instead index a same-named local branch or tag. Adding an unrelated ref changes which commit the configured branch denotes. A full-then-delta repository check reproduces searchable content from the wrong branch. The frequency of this non-default configuration is unmeasured.
Options documents BranchPrefix as the prefix of the branch to index, with remotes/origin as its example. The deployable zoekt-git-index exposes -prefix for branch names and forwards it into Options. getCommit at lines 180–195 first resolves ref alone and joins the prefix only after an error. Thus refs/remotes/origin/main and a different refs/heads/main collapse to the unprefixed lookup when both exist. prepareDeltaBuild uses this helper for current branches and also uses direct hashes for previous versions; compatibility with those explicit revisions matters.
The native check on prop_ab54hsvfh6 runs `go test ./gitindex -run '^TestPerfloopCommitBranchPrefix$' -count=1 -timeout=180s -v`. checkProperty call_UqCEvfD7vTn3yvm4HJfmU3hQ exited 1 without timeout, build failure or truncation. Of eight namespace histories, the two without competitors pass and all six containing a competing head or tag resolve the wrong commit. Qualified-ref, literal-hash and HEAD controls pass. In the integration history, the initial full index correctly reads origin/main. After that remote ref advances and a local main is added, successful delta indexing reaches prepareDeltaBuild with no fallback and search returns wrong-ref payload instead of the remote branch’s new payload. Both refs and commits are ordinary repository objects; no race or hostile actor is required.
The smallest useful Case check is the retained one-prefix/one-competing-head replay, followed by the existing full-then-delta integration. Establish namespace identity while retaining supported explicit-revision behavior. The bounded native checker is a provisional method, not a frozen layout requirement. Resolving the configured remote commit with unchanged direct-revision controls supports the repair; an explicit documented exclusion of short names with nonempty prefixes would contradict the proposed contract.
The actual getCommit hunk in https://github.com/sourcegraph/zoekt/pull/941 at head d8913787027de441c089e30121564a878a424fb5 changes filepath.Join to path.Join but retains unprefixed-first resolution. This namespace-selection outcome is distinct from its platform-path change. Concrete getCommit/prefix repair searches found no equivalent detail; the returned Git-input-failure repair concerns publication after reader errors, not ref identity. CONTRIBUTING.md names GitHub PR review and no separate archive, and bounded recent gitindex/index.go history showed no precedence repair. The repair adds a ref-kind distinction to a small shared helper, so explicit revision compatibility is part of its proof rather than optional hardening.
Change to test: Use the configured namespace to resolve short branch names instead of silently substituting a same-named ref elsewhere. Preserve direct meanings for explicit qualified refs, literal commit hashes and HEAD, including the hash lookups used for previously indexed versions.
Where it lives
perfloop-oss/zoekt · gitindex/index.go
Evidence
The check fails before this change and passes with it: `With a nonempty branch prefix, getCommit resolves short branch names in the requested namespace without substituting a competing head or tag; the tested full refs, full hashes, HEAD, parent revisions and empty-prefix lookups retain their direct meanings.`
The check fails before this change and passes with it: `After a remote main advances and a competing local main is added, full-then-delta indexing of main with prefix refs/remotes/origin publishes the remote content and branch commit in the tested repository.`
Checks: 1 of 1 passed. Verification: no defect found.
Timeline
2026-11-10· Case opened2026-11-10· PR opened