1 require 'git/internal/object'
2 require 'git/internal/pack'
3 require 'git/internal/loose'
8 def initialize(git_dir)
12 def get_object_by_sha1(sha1)
13 r = get_raw_object_by_sha1(sha1)
18 return Blob.new(r, self)
20 return Tree.new(r, self)
22 return Commit.new(r, self)
24 return Tag.new(r, self)
26 raise RuntimeError, "got invalid object-type"
30 def get_raw_object_by_sha1(sha1)
31 sha1 = [sha1].pack("H*")
32 packs = Dir.glob(@git_dir + '/objects/pack/pack-*.pack')
36 storage = Git::Internal::PackStorage.new(pack)
42 storage = Git::Internal::LooseStorage.new(@git_dir+'/objects')
46 # try packs again, maybe the object got packed in the meantime
48 storage = Git::Internal::PackStorage.new(pack)