Reduce the number of Gitaly calls for submodules

What does this MR do?

Optimize the number of Gitaly calls for submodules. This commit optimizes the backend performance of https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/29261

Related issue

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

Merge request reports

Loading