summaryrefslogtreecommitdiff
path: root/lib/gitlab/git_access.rb
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2018-03-29 16:10:43 -0700
committerStan Hu <stanhu@gmail.com>2018-04-06 08:17:07 -0700
commita18eea8c32381b9514083e796a8504fdfc2c81d9 (patch)
tree85643264b363a582baf884d2df518450323d13aa /lib/gitlab/git_access.rb
parent44f4a674e2a87d104f700265d835aba000c589f0 (diff)
downloadgitlab-ce-a18eea8c32381b9514083e796a8504fdfc2c81d9.tar.gz
Automatically cleanup stale worktrees and lock files upon a push
git 2.16 will fail badly if there are stale worktrees. Closes #44115
Diffstat (limited to 'lib/gitlab/git_access.rb')
-rw-r--r--lib/gitlab/git_access.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/gitlab/git_access.rb b/lib/gitlab/git_access.rb
index 6a01957184d..01f8b22b2b6 100644
--- a/lib/gitlab/git_access.rb
+++ b/lib/gitlab/git_access.rb
@@ -238,6 +238,11 @@ module Gitlab
end
def check_change_access!(changes)
+ # If there are worktrees with a HEAD pointing to a non-existent object,
+ # calls to `git rev-list --all` will fail in git 2.15+. This should also
+ # clear stale lock files.
+ project.repository.clean_stale_repository_files
+
changes_list = Gitlab::ChangesList.new(changes)
# Iterate over all changes to find if user allowed all of them to be applied