[VersionControl] Fix concurrency in query thread.

Fixes bugs #11662, #13225, #13241, #13814, #14581.
When we did a recursive=true call, we didn't use the query thread, which
caused multiple entries in native libraries.
This fixes it so recursive=true will make the caller wait for the query
to finish.