search: refactor to not mutate resolveRepositories struct
Created by: rvantonder
Addresses https://github.com/sourcegraph/sourcegraph/pull/13164#discussion_r473796356
This sort of refactor is a little scarier, esp because resolveRepositories
is big and finding the right place to create local vars... yeah...
Added this function to https://github.com/sourcegraph/sourcegraph/issues/13311 as a candidate to break up.