Skip to content

Commit

Permalink
fix warnings on Ruby 1.9
Browse files Browse the repository at this point in the history
  • Loading branch information
Lee Jarvis committed Jun 9, 2011
1 parent d4ed1eb commit bd908d7
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 67 deletions.
2 changes: 1 addition & 1 deletion lib/grit/commit.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Commit
lazy_reader :committed_date lazy_reader :committed_date
lazy_reader :message lazy_reader :message
lazy_reader :short_message lazy_reader :short_message
lazy_reader :author_string # lazy_reader :author_string


# Parses output from the `git-cat-file --batch'. # Parses output from the `git-cat-file --batch'.
# #
Expand Down
2 changes: 0 additions & 2 deletions lib/grit/git-ruby/file_index.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ class << self


self.max_file_size = 10_000_000 # ~10M self.max_file_size = 10_000_000 # ~10M


attr_reader :files

# initializes index given repo_path # initializes index given repo_path
def initialize(repo_path) def initialize(repo_path)
@index_file = File.join(repo_path, 'file-index') @index_file = File.join(repo_path, 'file-index')
Expand Down
3 changes: 2 additions & 1 deletion lib/grit/git-ruby/git_object.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -290,7 +290,8 @@ def raw_log(sha)
end end


class Tag < GitObject class Tag < GitObject
attr_accessor :object, :type, :tag, :tagger, :message attr_accessor :object, :tag, :tagger, :message
attr_writer :type


def self.from_raw(rawobject, repository=nil) def self.from_raw(rawobject, repository=nil)


Expand Down
120 changes: 60 additions & 60 deletions lib/grit/git-ruby/repository.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -475,60 +475,60 @@ def diff(commit1, commit2, options = {})
# [full_path, 'modified', tree1_hash, tree2_hash] # [full_path, 'modified', tree1_hash, tree2_hash]
# ] # ]
def quick_diff(tree1, tree2, path = '.', recurse = true) def quick_diff(tree1, tree2, path = '.', recurse = true)
# handle empty trees # handle empty trees
changed = [] changed = []
return changed if tree1 == tree2 return changed if tree1 == tree2


t1 = list_tree(tree1) if tree1 t1 = list_tree(tree1) if tree1
t2 = list_tree(tree2) if tree2 t2 = list_tree(tree2) if tree2


# finding files that are different # finding files that are different
t1['blob'].each do |file, hsh| t1['blob'].each do |file, hsh|
t2_file = t2['blob'][file] rescue nil t2_file = t2['blob'][file] rescue nil
full = File.join(path, file) full = File.join(path, file)
if !t2_file if !t2_file
changed << [full, 'added', hsh[:sha], nil] # not in parent changed << [full, 'added', hsh[:sha], nil] # not in parent
elsif (hsh[:sha] != t2_file[:sha]) elsif (hsh[:sha] != t2_file[:sha])
changed << [full, 'modified', hsh[:sha], t2_file[:sha]] # file changed changed << [full, 'modified', hsh[:sha], t2_file[:sha]] # file changed
end end
end if t1 end if t1
t2['blob'].each do |file, hsh| t2['blob'].each do |file, hsh|
if !t1 || !t1['blob'][file] if !t1 || !t1['blob'][file]
changed << [File.join(path, file), 'removed', nil, hsh[:sha]] changed << [File.join(path, file), 'removed', nil, hsh[:sha]]
end end
end if t2 end if t2


t1['tree'].each do |dir, hsh| t1['tree'].each do |dir, hsh|
t2_tree = t2['tree'][dir] rescue nil t2_tree = t2['tree'][dir] rescue nil
full = File.join(path, dir) full = File.join(path, dir)
if !t2_tree if !t2_tree
if recurse if recurse
changed += quick_diff(hsh[:sha], nil, full, true) changed += quick_diff(hsh[:sha], nil, full, true)
else else
changed << [full, 'added', hsh[:sha], nil] # not in parent changed << [full, 'added', hsh[:sha], nil] # not in parent
end end
elsif (hsh[:sha] != t2_tree[:sha]) elsif (hsh[:sha] != t2_tree[:sha])
if recurse if recurse
changed += quick_diff(hsh[:sha], t2_tree[:sha], full, true) changed += quick_diff(hsh[:sha], t2_tree[:sha], full, true)
else else
changed << [full, 'modified', hsh[:sha], t2_tree[:sha]] # file changed changed << [full, 'modified', hsh[:sha], t2_tree[:sha]] # file changed
end end
end end
end if t1 end if t1
t2['tree'].each do |dir, hsh| t2['tree'].each do |dir, hsh|
t1_tree = t1['tree'][dir] rescue nil t1_tree = t1['tree'][dir] rescue nil
full = File.join(path, dir) full = File.join(path, dir)
if !t1_tree if !t1_tree
if recurse if recurse
changed += quick_diff(nil, hsh[:sha], full, true) changed += quick_diff(nil, hsh[:sha], full, true)
else else
changed << [full, 'removed', nil, hsh[:sha]] changed << [full, 'removed', nil, hsh[:sha]]
end end
end end
end if t2 end if t2


changed changed
end end


# returns true if the files in path_limiter were changed, or no path limiter # returns true if the files in path_limiter were changed, or no path limiter
# used by the log() function when passed with a path_limiter # used by the log() function when passed with a path_limiter
Expand All @@ -551,9 +551,9 @@ def get_subtree(commit_sha, path)


if path && !(path == '' || path == '.' || path == './') if path && !(path == '' || path == '.' || path == './')
paths = path.split('/') paths = path.split('/')
paths.each do |path| paths.each do |pathname|
tree = get_object_by_sha1(tree_sha) tree = get_object_by_sha1(tree_sha)
if entry = tree.entry.select { |e| e.name == path }.first if entry = tree.entry.select { |e| e.name == pathname }.first
tree_sha = entry.sha1 rescue nil tree_sha = entry.sha1 rescue nil
else else
return false return false
Expand Down Expand Up @@ -720,9 +720,9 @@ def each_alternate_path(path)
end end
end end


def load_alternate_loose(path) def load_alternate_loose(pathname)
# load alternate loose, too # load alternate loose, too
each_alternate_path path do |path| each_alternate_path pathname do |path|
next if @loaded.include?(path) next if @loaded.include?(path)
next if !File.exist?(path) next if !File.exist?(path)
load_loose(path) load_loose(path)
Expand All @@ -745,8 +745,8 @@ def initpacks
@packs @packs
end end


def load_alternate_packs(path) def load_alternate_packs(pathname)
each_alternate_path path do |path| each_alternate_path pathname do |path|
full_pack = File.join(path, 'pack') full_pack = File.join(path, 'pack')
next if @loaded_packs.include?(full_pack) next if @loaded_packs.include?(full_pack)
load_packs(full_pack) load_packs(full_pack)
Expand Down
6 changes: 3 additions & 3 deletions lib/grit/repo.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -436,8 +436,8 @@ def commit_deltas_from(other_repo, ref = "master", other_ref = "master")
repo_refs = self.git.rev_list({}, ref).strip.split("\n") repo_refs = self.git.rev_list({}, ref).strip.split("\n")
other_repo_refs = other_repo.git.rev_list({}, other_ref).strip.split("\n") other_repo_refs = other_repo.git.rev_list({}, other_ref).strip.split("\n")


(other_repo_refs - repo_refs).map do |ref| (other_repo_refs - repo_refs).map do |refn|
Commit.find_all(other_repo, ref, {:max_count => 1}).first Commit.find_all(other_repo, refn, {:max_count => 1}).first
end end
end end


Expand Down Expand Up @@ -491,7 +491,7 @@ def tree(treeish = 'master', paths = [])
end end


# quick way to get a simple array of hashes of the entries # quick way to get a simple array of hashes of the entries
# of a single tree or recursive tree listing from a given # of a single tree or recursive tree listing from a given
# sha or reference # sha or reference
# +treeish+ is the reference (default 'master') # +treeish+ is the reference (default 'master')
# +options+ is a hash or options - currently only takes :recursive # +options+ is a hash or options - currently only takes :recursive
Expand Down

0 comments on commit bd908d7

Please sign in to comment.