Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2018-12-26 21:24:16 +0300
committerOswaldo Ferreira <>2019-04-19 04:01:51 +0300
commit26653eb0359002e9991bf5089c5505b566125f26 (patch)
treeb4a10088456c99fc36b0bd378143ae8abc8a822c /lib/gitlab/git
parent9ec37d3dc1c1969be743a0c283242dc462a8f466 (diff)
Don't create a temp reference for branch comparisons within project
A temp reference is only needed to fetch a branch from another project, as in the case for forked repositories. For branch comparisons within the same project, we can just use the existing branch names to do the comparison. Relates to https://gitlab.com/gitlab-org/gitlab-ce/issues/38689#note_126107862
Diffstat (limited to 'lib/gitlab/git')
-rw-r--r--lib/gitlab/git/repository.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb
index a22e3c4b9dd..6cebc9ac9eb 100644
--- a/lib/gitlab/git/repository.rb
+++ b/lib/gitlab/git/repository.rb
@@ -732,6 +732,12 @@ module Gitlab
end
def compare_source_branch(target_branch_name, source_repository, source_branch_name, straight:)
+ if source_repository == self
+ return unless commit(source_branch_name).present?
+
+ return Gitlab::Git::Compare.new(self, target_branch_name, source_branch_name, straight: straight)
+ end
+
tmp_ref = "refs/tmp/#{SecureRandom.hex}"
return unless fetch_source_branch!(source_repository, source_branch_name, tmp_ref)
@@ -743,7 +749,7 @@ module Gitlab
straight: straight
)
ensure
- delete_refs(tmp_ref)
+ delete_refs(tmp_ref) if tmp_ref
end
def write_ref(ref_path, ref, old_ref: nil)