Skip to content

index: preserve matched branches in filename-only searches - #1297

Open
perfloop-agent wants to merge 2 commits into
sourcegraph:mainfrom
perfloop-oss:perfloop-pr-open-3ym993gb7r
Open

perfloop-agent wants to merge 2 commits into
sourcegraph:mainfrom
perfloop-oss:perfloop-pr-open-3ym993gb7r

Conversation

@perfloop-agent

@perfloop-agent perfloop-agent commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Filename-only searches can point multi-branch file results at the wrong commit. This fixes branch-filtered type:file and type:filename queries without changing their filename-only output or scores.

cc @keegancsmith @stefanhengl

For a file shared by main@sha-main, dev@sha-dev and release@sha-release, type:file branch:dev hello currently reports [main dev release] and sha-main. It now reports [dev] and sha-dev. Subrepository versions follow that branch by name even when their branch list is reordered or shorter. A missing branch version is left empty.

Branch selection now visits matched atoms inside filename-only wrappers. Fragment gathering and atom scoring still skip those children: the wrapper controls what is displayed, not which branch filters apply. Unmatched alternatives and negated filters remain excluded from branch collection. Queries without a matched positive branch filter retain the existing all-containing-branches fallback.

Local measurement: type:file func over 48 committed index Go files took 325,397.5 ns/search on Base and 325,365.5 ns/search on Patched (72 pairs). Paired Patched-minus-Base change: −437 ns/search, interval −2,650 to +7,236 ns/search; inconclusive.

Test coverage

TestTypeFileNameBranches in index/eval_test.go covers composed branch filters, wrapper placements and parsed queries. TestSubRepoBranchVersions in index/eval_test.go covers unaligned and missing subrepository branches. The scoring check in index/index_test.go reuses the existing filename-only fixture.

Go index package tests passed.

The full-suite CI test job is left to target CI.

Case and evidence


Made by Perfloop. Human sponsor: Tomás Senart.

@keegancsmith keegancsmith left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! ya need to rebase

Signed-off-by: Perfloop Agent <agent@perfloop.ai>
Signed-off-by: Perfloop Agent <agent@perfloop.ai>
@perfloop
perfloop Bot force-pushed the perfloop-pr-open-3ym993gb7r branch 2 times, most recently from 33eed9e to b08b5a4 Compare December 1, 2026 17:19
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.

2 participants