lib/grit/git-ruby/repository.rb in mojombo-grit-0.9.4 vs lib/grit/git-ruby/repository.rb in mojombo-grit-1.1.1

- old
+ new

@@ -183,20 +183,19 @@ end def get_raw_tree(sha) o = get_raw_object_by_sha1(sha) if o.type == :commit - tree = cat_file(get_object_by_sha1(sha).tree) + cat_file(get_object_by_sha1(sha).tree) elsif o.type == :tag commit_sha = get_object_by_sha1(sha).object - tree = cat_file(get_object_by_sha1(commit_sha).tree) - else - tree = cat_file(sha) + cat_file(get_object_by_sha1(commit_sha).tree) + elsif o.type == :tree + cat_file(sha) end - return tree end - + # return array of tree entries ## TODO : refactor this to remove the fugly def ls_tree_path(sha, path, append = nil) tree = get_raw_tree(sha) if path =~ /\// @@ -662,10 +661,11 @@ end private def initloose + @loaded = [] @loose = [] load_loose(git_path('objects')) load_alternate_loose(git_path('objects')) @loose end @@ -673,26 +673,29 @@ def load_alternate_loose(path) # load alternate loose, too alt = File.join(path, 'info/alternates') if File.exists?(alt) File.readlines(alt).each do |line| + next if @loaded.include?(line.chomp) if line[0, 2] == '..' line = File.expand_path(File.join(@git_dir, line)) end load_loose(line.chomp) load_alternate_loose(line.chomp) end end end def load_loose(path) + @loaded << path return if !File.exists?(path) @loose << Grit::GitRuby::Internal::LooseStorage.new(path) end def initpacks close + @loaded_packs = [] @packs = [] load_packs(git_path("objects/pack")) load_alternate_packs(git_path('objects')) @packs end @@ -703,16 +706,18 @@ File.readlines(alt).each do |line| if line[0, 2] == '..' line = File.expand_path(File.join(@git_dir, line)) end full_pack = File.join(line.chomp, 'pack') + next if @loaded_packs.include?(full_pack) load_packs(full_pack) load_alternate_packs(File.join(line.chomp)) end end end def load_packs(path) + @loaded_packs << path return if !File.exists?(path) Dir.open(path) do |dir| dir.each do |entry| next if !(entry =~ /\.pack$/i) pack = Grit::GitRuby::Internal::PackStorage.new(File.join(path,entry))