`Projects::Settings::RepositoryController#show` executes more than 100 SQL queries

This controller action executes more than 100 SQL queries, the maximum number of queries allowed after the changes in the MR: !162208 (merged). This cause ee/spec/features/projects/settings/ee/protected_branches_spec.rb to fail (example).

The number of queries should be reduced to less than 100 and the corresponding allow-listed sections of code (Gitlab::QueryLimiting.disable!('...')) should be removed. The following tests should pass:

  • ee/spec/features/projects/settings/ee/protected_branches_spec.rb
  • ee/spec/features/protected_branches_spec.rb
  • spec/features/protected_branches_spec.rb