Don't create a temp reference for branch comparisons within project
A temp reference is only needed to fetch a branch from another project, as in the case for forked repositories. For branch comparisons within the same project, we can just use the existing branch names to do the comparison.
Relates to #38689 (comment 126107862)
Locally with a few more than 7 discussions it was taking 38 RPC requests (405ms). Now it's taking 19 RPC requests (61ms). Great improvements!
We'll have considerable improvements taking it along with #58297 (closed).
Closes #58315 (closed)