lib/gitlab_git/repository.rb in gitlab_git-7.2.10 vs lib/gitlab_git/repository.rb in gitlab_git-7.2.11
- old
+ new
@@ -275,10 +275,16 @@
options = default_options.merge(options)
options[:limit] ||= 0
options[:offset] ||= 0
actual_ref = options[:ref] || root_ref
- sha = sha_from_ref(actual_ref)
+ begin
+ sha = sha_from_ref(actual_ref)
+ rescue Rugged::OdbError, Rugged::InvalidError, Rugged::ReferenceError
+ # Return an empty array if the ref wasn't found
+ return []
+ end
+
repo = options[:repo]
cmd = %W(git --git-dir=#{path} log)
cmd += %W(-n #{options[:limit].to_i})
cmd += %W(--format=%H)