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)
15 Object.from_raw(r, self)
18 def get_raw_object_by_sha1(sha1)
19 sha1 = [sha1].pack("H*")
20 packs = Dir.glob(@git_dir + '/objects/pack/pack-*.pack')
24 storage = Git::Internal::PackStorage.new(pack)
30 storage = Git::Internal::LooseStorage.new(@git_dir+'/objects')
34 # try packs again, maybe the object got packed in the meantime
36 storage = Git::Internal::PackStorage.new(pack)
48 r = Git::Repository.new(ARGV[0])
49 ARGV[1..-1].each do |sha1|
50 o = r.get_object_by_sha1(sha1)
60 puts o.entry.collect { |e| "%s %s" % [e.sha1, e.name] }.join("\n")