1 require 'git/internal/object'
2 require 'git/internal/pack'
3 require 'git/internal/loose'
7 def initialize(git_dir)
11 def get_object_by_sha1(sha1)
12 r = get_raw_object_by_sha1(sha1)
17 return Blob.new(r, self)
19 return Tree.new(r, self)
21 return Commit.new(r, self)
23 return Tag.new(r, self)
25 raise RuntimeError, "got invalid object-type"
29 def get_raw_object_by_sha1(sha1)
30 sha1 = [sha1].pack("H*")
31 packs = Dir.glob(@git_dir + '/objects/pack/pack-*.pack')
35 storage = Git::Internal::PackStorage.new(pack)
41 storage = Git::Internal::LooseStorage.new(@git_dir+'/objects')
45 # try packs again, maybe the object got packed in the meantime
47 storage = Git::Internal::PackStorage.new(pack)