Optimize commit and diff changes access check to reduce git operations
Git operations are costly. Before, if file locks and all file locks were enabled we would iterate over each commit twice and over each diff as much as 4 times. This updates uses lambdas to go through all neccessary validations in only one iteration per commit and per diff. It also removes some unused code in lib/gitlab/git_access.rb and adds examples to ensure the code keeps working as intended.
Related to https://gitlab.com/gitlab-org/gitlab-ce/issues/14280
Valery: Closes https://gitlab.com/gitlab-org/gitlab-ee/issues/880