From bb06b566cdd58a7e7a9286d3828506a2c45f38c7 Mon Sep 17 00:00:00 2001 From: risk Date: Thu, 14 Jul 2011 14:30:23 -0700 Subject: [PATCH] GitAccess#ref_to_sha should never return a blank string --- lib/gollum/git_access.rb | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/gollum/git_access.rb b/lib/gollum/git_access.rb index 21444f68..9fe5298e 100644 --- a/lib/gollum/git_access.rb +++ b/lib/gollum/git_access.rb @@ -28,13 +28,17 @@ module Gollum # # ref - a String Git reference (ex: "master") # - # Returns a String. + # Returns a String, or nil if the ref isn't found. def ref_to_sha(ref) - if sha?(ref) - ref - else - get_cache(:ref, ref) { ref_to_sha!(ref) } - end + ref = ref.to_s + return if ref.empty? + sha = + if sha?(ref) + ref + else + get_cache(:ref, ref) { ref_to_sha!(ref) } + end.to_s + sha.empty? ? nil : sha end # Public: Gets a recursive list of Git blobs for the whole tree at the @@ -238,4 +242,4 @@ module Gollum path end end -end \ No newline at end of file +end