Skip to content

Commit

Permalink
Repository#file_at: don't throw an exception on nonexistent path
Browse files Browse the repository at this point in the history
If the path doesn't exist, trying to access blob_data[:oid] would
throw a NoMethodError. Check whether the file exists and return nil if
it doesn't instead.
  • Loading branch information
carlosmn committed Apr 9, 2012
1 parent f3dc8fb commit cb41776
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions lib/rugged/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def file_at(revision, path)
tree = Rugged::Commit.lookup(self, revision).tree
subtree = tree.get_subtree(path)
blob_data = subtree.get_entry(File.basename path)
return nil unless blob_data
blob = Rugged::Blob.lookup(self, blob_data[:oid])
blob.content
end
Expand Down

0 comments on commit cb41776

Please sign in to comment.