From 41d438b47e8ee83a66705f6c04106662e6ea922f Mon Sep 17 00:00:00 2001 From: Vicent Marti Date: Fri, 25 Sep 2015 08:35:34 -0700 Subject: [PATCH] repository: Do not attempt to scan large repos --- lib/linguist/repository.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/linguist/repository.rb b/lib/linguist/repository.rb index 01e595da..51040734 100644 --- a/lib/linguist/repository.rb +++ b/lib/linguist/repository.rb @@ -126,12 +126,13 @@ module Linguist end protected + MAX_TREE_SIZE = 100_000 def compute_stats(old_commit_oid, cache = nil) + return {} if current_tree.count_recursive(MAX_TREE_SIZE) >= MAX_TREE_SIZE + old_tree = old_commit_oid && Rugged::Commit.lookup(repository, old_commit_oid).tree - read_index - diff = Rugged::Tree.diff(repository, old_tree, current_tree) # Clear file map and fetch full diff if any .gitattributes files are changed