0
require 'grit/git-ruby/internal/raw_object'
0
require 'grit/git-ruby/internal/pack'
0
require 'grit/git-ruby/internal/loose'
0
-require 'grit/git-ruby/
object'
0
+require 'grit/git-ruby/
git_object'
0
@@ -28,6 +28,9 @@ module Grit
0
class NoSuchShaFound < StandardError
0
+ class NoSuchPath < StandardError
0
attr_accessor :git_dir, :options
0
@@ -96,7 +99,7 @@ module Grit
0
def get_object_by_sha1(sha1)
0
r = get_raw_object_by_sha1(sha1)
0
# writes a raw object into the git repo
0
@@ -149,7 +152,7 @@ module Grit
0
# ['blob']['FILENAME'] = {:mode => '100644', :sha => SHA}
0
# ['tree']['DIRNAME'] = {:mode => '040000', :sha => SHA}
0
- data = {'blob' => {}, 'tree' => {}
}
0
+ data = {'blob' => {}, 'tree' => {}
, 'link' => {}, 'commit' => {}}
0
get_object_by_sha1(sha).entry.each do |e|
0
data[e.format_type][e.name] = {:mode => e.format_mode, :sha => e.sha1}
0
@@ -176,6 +179,9 @@ module Grit
0
o = get_raw_object_by_sha1(sha)
0
tree = cat_file(get_object_by_sha1(sha).tree)
0
+ commit_sha = get_object_by_sha1(sha).object
0
+ tree = cat_file(get_object_by_sha1(commit_sha).tree)
0
@@ -192,6 +198,7 @@ module Grit
0
if (last == '/') && (paths.size == 1)
0
append = append ? File.join(append, paths.first) : paths.first
0
dir_name = tree.split("\n").select { |p| p.split("\t")[1] == paths.first }.first
0
+ raise NoSuchPath if !dir_name
0
next_sha = dir_name.split(' ')[2]
0
tree = get_raw_tree(next_sha)
0
tree = tree.split("\n")
0
@@ -208,6 +215,7 @@ module Grit
0
next_path = paths.shift
0
dir_name = tree.split("\n").select { |p| p.split("\t")[1] == next_path }.first
0
+ raise NoSuchPath if !dir_name
0
next_sha = dir_name.split(' ')[2]
0
next_path = append ? File.join(append, next_path) : next_path
0
@@ -264,7 +272,7 @@ module Grit
0
log = log(sha, options)
0
log = log.sort { |a, b| a[2] <=> b[2] }.reverse
0
log = truncate_arr(log, end_sha)
0
@@ -282,9 +290,14 @@ module Grit
0
@already_searched[sha] = true
0
o = get_raw_object_by_sha1(sha)
0
- c = Object.from_raw(o)
0
+ commit_sha = get_object_by_sha1(sha).object
0
+ c = get_object_by_sha1(commit_sha)
0
+ c = GitObject.from_raw(o)
0
@@ -347,7 +360,9 @@ module Grit
0
tree2 = get_object_by_sha1(commit_obj1.parent.first).tree
0
qdiff = quick_diff(tree1, tree2)
0
qdiff.sort.each do |diff_arr|
0
format, lines, output = :unified, 3, ''
0
file_length_difference = 0
0
@@ -362,7 +377,7 @@ module Grit
0
data_new = fileB.split(/\n/).map! { |e| e.chomp }
0
diffs = Difference::LCS.diff(data_old, data_new)
0
- return
if diffs.empty?
0
+ return
'' if diffs.empty?
0
header = 'diff --git a/' + diff_arr[0].gsub('./', '') + ' b/' + diff_arr[0].gsub('./', '')
0
if options[:full_index]
0
@@ -402,6 +417,8 @@ module Grit
0
patch << header + output.lstrip
0
+ '' # one of the trees was bad or lcs isn't there - no diff
0
# takes 2 tree shas and recursively walks them to find out what
0
@@ -418,7 +435,7 @@ module Grit
0
t1 = list_tree(tree1) if tree1
0
t2 = list_tree(tree2) if tree2
0
# finding files that are different
0
t1['blob'].each do |file, hsh|
0
t2_file = t2['blob'][file] rescue nil
0
@@ -430,9 +447,9 @@ module Grit
0
t2['blob'].each do |file, hsh|
0
+ if !t1
|| !t1['blob'][file]
0
changed << [File.join(path, file), 'removed', nil, hsh[:sha]]
0
t1['tree'].each do |dir, hsh|
0
@@ -453,7 +470,7 @@ module Grit
0
t2['tree'].each do |dir, hsh|
0
- t1_tree = t
2['tree'][dir] rescue nil
0
+ t1_tree = t
1['tree'][dir] rescue nil
0
full = File.join(path, dir)
0
@@ -585,23 +602,35 @@ module Grit
0
- if f = File.exists?(git_path("objects/pack"))
0
- Dir.open(git_path("objects/pack/")) do |dir|
0
- if entry =~ /\.pack$/i
0
- pack = Grit::GitRuby::Internal::PackStorage.new(git_path("objects/pack/" + entry))
0
- if @options[:map_packfile]
0
+ load_packs(git_path("objects/pack"))
0
+ # load alternate packs, too
0
+ alt = git_path('objects/info/alternates')
0
+ File.readlines(alt).each do |line|
0
+ full_pack = File.join(line.chomp, 'pack')
0
+ return if !File.exists?(path)
0
+ Dir.open(path) do |dir|
0
+ next if !(entry =~ /\.pack$/i)
0
+ pack = Grit::GitRuby::Internal::PackStorage.new(File.join(path,entry))
0
+ if @options[:map_packfile]