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>2019-03-06 21:36:28 +0300
committerStan Hu <stanhu@gmail.com>2019-03-07 15:29:57 +0300
commit28883d8e449acc6cb8ad6f0312d77a8ee5027e75 (patch)
treebb7ba6655708dbdb053530cc2a8f79e26d5faef3
parent2c4cb7a6a851d0c49077518a5dd0c289526a66e6 (diff)
Remove old code in TreeHelper#flatten_tree
-rw-r--r--app/helpers/tree_helper.rb11
-rw-r--r--lib/gitlab/git/rugged_impl/tree.rb8
2 files changed, 6 insertions, 13 deletions
diff --git a/app/helpers/tree_helper.rb b/app/helpers/tree_helper.rb
index e2879bfdcf1..c5bab877c00 100644
--- a/app/helpers/tree_helper.rb
+++ b/app/helpers/tree_helper.rb
@@ -136,18 +136,9 @@ module TreeHelper
end
# returns the relative path of the first subdir that doesn't have only one directory descendant
- # rubocop: disable CodeReuse/ActiveRecord
def flatten_tree(root_path, tree)
- return tree.flat_path.sub(%r{\A#{Regexp.escape(root_path)}/}, '') if tree.flat_path.present?
-
- subtree = Gitlab::Git::Tree.where(@repository, @commit.id, tree.path)
- if subtree.count == 1 && subtree.first.dir?
- return tree_join(tree.name, flatten_tree(root_path, subtree.first))
- else
- return tree.name
- end
+ tree.flat_path.sub(%r{\A#{Regexp.escape(root_path)}/}, '')
end
- # rubocop: enable CodeReuse/ActiveRecord
def selected_branch
@branch_name || tree_edit_branch
diff --git a/lib/gitlab/git/rugged_impl/tree.rb b/lib/gitlab/git/rugged_impl/tree.rb
index c1205bca1d2..f6ddc4e4346 100644
--- a/lib/gitlab/git/rugged_impl/tree.rb
+++ b/lib/gitlab/git/rugged_impl/tree.rb
@@ -33,9 +33,11 @@ module Gitlab
end
end
- # This is an optimization to reduce N+1 queries for Gitaly. It's
- # currently done in TreeHelper#flatten_tree, but to emulate Gitaly
- # as much as possible we populate the value here.
+ # This was an optimization to reduce N+1 queries for Gitaly
+ # (https://gitlab.com/gitlab-org/gitaly/issues/530). It
+ # used to be done lazily in the view via
+ # TreeHelper#flatten_tree, so it's possible there's a
+ # performance impact by loading this eagerly.
rugged_populate_flat_path(repository, sha, path, ordered_entries)
end