summaryrefslogtreecommitdiff
path: root/app/controllers/projects/tree_controller.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-03-30 13:38:24 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2023-03-30 13:38:24 +0000
commitd6192c2ab77ab814b9bd66103663047556fd67e4 (patch)
tree78253d9abc4a68b07c0013e4d8448f0104cd199d /app/controllers/projects/tree_controller.rb
parent5e57ed483af358e2404891d87d1f68a8cf60ef89 (diff)
downloadgitlab-ce-d6192c2ab77ab814b9bd66103663047556fd67e4.tar.gz
Add latest changes from gitlab-org/security/gitlab@15-9-stable-eev15.9.4
Diffstat (limited to 'app/controllers/projects/tree_controller.rb')
-rw-r--r--app/controllers/projects/tree_controller.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/app/controllers/projects/tree_controller.rb b/app/controllers/projects/tree_controller.rb
index 737a6290431..1f7912e15df 100644
--- a/app/controllers/projects/tree_controller.rb
+++ b/app/controllers/projects/tree_controller.rb
@@ -28,6 +28,15 @@ class Projects::TreeController < Projects::ApplicationController
def show
return render_404 unless @commit
+ @ref_type = ref_type
+ if @ref_type == BRANCH_REF_TYPE && ambiguous_ref?(@project, @ref)
+ branch = @project.repository.find_branch(@ref)
+ if branch
+ redirect_to project_tree_path(@project, branch.target)
+ return
+ end
+ end
+
if tree.entries.empty?
if @repository.blob_at(@commit.id, @path)
redirect_to project_blob_path(@project, File.join(@ref, @path))