diff options
author | scott Chacon <schacon@agadorsparticus.corp.reactrix.com> | 2007-11-20 13:24:44 -0800 |
---|---|---|
committer | scott Chacon <schacon@agadorsparticus.corp.reactrix.com> | 2007-11-20 13:24:44 -0800 |
commit | 90dea6d415bfc5734bc87c2797b26cca311246bc (patch) | |
tree | ca17b784c0f417bb62fde17e9b11a1a8a444c07e /lib/git/raw/git.rb | |
parent | d07a2c04c1599fe707831afdd29397cc36e02fa6 (diff) | |
download | third_party-ruby-git-90dea6d415bfc5734bc87c2797b26cca311246bc.tar.gz third_party-ruby-git-90dea6d415bfc5734bc87c2797b26cca311246bc.tar.xz third_party-ruby-git-90dea6d415bfc5734bc87c2797b26cca311246bc.zip |
have the pure ruby bindings working to some degree
Diffstat (limited to 'lib/git/raw/git.rb')
-rw-r--r-- | lib/git/raw/git.rb | 63 |
1 files changed, 0 insertions, 63 deletions
diff --git a/lib/git/raw/git.rb b/lib/git/raw/git.rb deleted file mode 100644 index 004e795..0000000 --- a/lib/git/raw/git.rb +++ /dev/null @@ -1,63 +0,0 @@ -require 'git/internal/object' -require 'git/internal/pack' -require 'git/internal/loose' -require 'git/object' - -module Git - class Repository - def initialize(git_dir) - @git_dir = git_dir - @loose = Internal::LooseStorage.new(git_path("objects")) - @packs = [] - initpacks - end - - def git_path(path) - return "#@git_dir/#{path}" - end - - def get_object_by_sha1(sha1) - r = get_raw_object_by_sha1(sha1) - return nil if !r - Object.from_raw(r, self) - end - - def get_raw_object_by_sha1(sha1) - sha1 = [sha1].pack("H*") - - # try packs - @packs.each do |pack| - o = pack[sha1] - return o if o - end - - # try loose storage - o = @loose[sha1] - return o if o - - # try packs again, maybe the object got packed in the meantime - initpacks - @packs.each do |pack| - o = pack[sha1] - return o if o - end - - nil - end - - def initpacks - @packs.each do |pack| - pack.close - end - @packs = [] - Dir.open(git_path("objects/pack/")) do |dir| - dir.each do |entry| - if entry =~ /\.pack$/i - @packs << Git::Internal::PackStorage.new(git_path("objects/pack/" \ - + entry)) - end - end - end - end - end -end |