Only load branch names for protected branch checks

What does this MR do?

This changes the code used for checking for protected branches so we only load the names into memory. This won't result in a big difference (if any) in SQL queries, it just reduces the amount of data being sent over the wire / loaded into memory.

Does this MR meet the acceptance criteria?

What are the relevant issue numbers?

https://gitlab.com/gitlab-org/gitlab-ce/issues/36878

Merge request reports

Loading