Skip to content

zoekt: handle multiple branches in zoektIndexedRepos

Administrator requested to merge k/multi-branch-search into master

Created by: keegancsmith

REVIEWERS NOTE: We don't have a way yet to associate results with the correct RepositoryRevision. IE if we merge this and there are multiple branches indexed, all results will be associated with the first branch in a repository revision (even if they came from another branch). We can safely merge now since we don't yet actually index multiple branches. However, I'm exploring how to achieve the above nicely and it may involve more involved changes to how zoektIndexedRepos and zoektSearchHEAD interact. So I will likely hold off merging this until I am satisfied with the approach. But this is safe to review now since the core of this PR won't change.

This teaches zoektIndexedRepos to handle branches other than HEAD. It uses the same logic in zoektSingleIndexedRepo to assign a Sourcegraph revspec to a zoekt branch. If we have indexed all the revspecs we want to search in repo we pass the query on to zoekt.

Note: The common case is to search only HEAD in all repos. This code change should be as performant, except we will now allocate a branches slice per repo. If this shows up in profiles we can optimize this. (eg a global var justHEAD = []string{"HEAD"} to reuse).

Note: We need to update the function to return the resolves branches to search in Zoekt. This will be done in a later commit.

Part of #6728

Merge request reports

Loading