Skip to content

Commit dd4706e

Browse files
author
Daniel Mendler
committed
initialize instance variables to prevent warnings,
add $VERBOSE = true for the tests
1 parent 05117d4 commit dd4706e

File tree

6 files changed

+37
-52
lines changed

6 files changed

+37
-52
lines changed

Rakefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ end
2424

2525
desc "Run Unit Tests"
2626
task :test do |t|
27+
$VERBOSE = true
2728
require File.dirname(__FILE__) + '/tests/all_tests.rb'
2829
end
2930

lib/git/base.rb

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,6 @@ module Git
22

33
class Base
44

5-
@working_directory = nil
6-
@repository = nil
7-
@index = nil
8-
9-
@lib = nil
10-
@logger = nil
11-
125
# opens a bare Git Repository - no working directory options
136
def self.bare(git_dir, opts = {})
147
self.new({:repository => git_dir}.merge(opts))
@@ -66,11 +59,13 @@ def initialize(options = {})
6659
if options[:log]
6760
@logger = options[:log]
6861
@logger.info("Starting Git")
62+
else
63+
@logger = nil
6964
end
70-
71-
@working_directory = Git::WorkingDirectory.new(options[:working_directory]) if options[:working_directory]
72-
@repository = Git::Repository.new(options[:repository]) if options[:repository]
73-
@index = Git::Index.new(options[:index], false) if options[:index]
65+
66+
@working_directory = options[:working_directory] ? Git::WorkingDirectory.new(options[:working_directory]) : nil
67+
@repository = options[:repository] ? Git::Repository.new(options[:repository]) : nil
68+
@index = options[:index] ? Git::Index.new(options[:index], false) : nil
7469
end
7570

7671

lib/git/diff.rb

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,15 @@ module Git
44
class Diff
55
include Enumerable
66

7-
@base = nil
8-
@from = nil
9-
@to = nil
10-
@path = nil
11-
12-
@full_diff = nil
13-
@full_diff_files = nil
14-
@stats = nil
15-
167
def initialize(base, from = nil, to = nil)
178
@base = base
189
@from = from.to_s
1910
@to = to.to_s
11+
12+
@path = nil
13+
@full_diff = nil
14+
@full_diff_files = nil
15+
@stats = nil
2016
end
2117
attr_reader :from, :to
2218

lib/git/lib.rb

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,12 @@ class GitExecuteError < StandardError
77

88
class Lib
99

10-
@git_dir = nil
11-
@git_index_file = nil
12-
@git_work_dir = nil
13-
@path = nil
14-
15-
@logger = nil
16-
1710
def initialize(base = nil, logger = nil)
11+
@git_dir = nil
12+
@git_index_file = nil
13+
@git_work_dir = nil
14+
@path = nil
15+
1816
if base.is_a?(Git::Base)
1917
@git_dir = base.repo.path
2018
@git_index_file = base.index.path if base.index

lib/git/log.rb

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,20 @@ module Git
44
class Log
55
include Enumerable
66

7-
@base = nil
8-
@commits = nil
9-
10-
@object = nil
11-
@path = nil
12-
@count = nil
13-
@since = nil
14-
@skip = nil
15-
@until = nil
16-
@between = nil
17-
18-
@dirty_flag = nil
19-
207
def initialize(base, count = 30)
218
dirty_log
229
@base = base
2310
@count = count
11+
12+
@commits = nil
13+
@author = nil
14+
@grep = nil
15+
@object = nil
16+
@path = nil
17+
@since = nil
18+
@skip = nil
19+
@until = nil
20+
@between = nil
2421
end
2522

2623
def object(objectish)

lib/git/object.rb

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,14 @@ class Object
88

99
class AbstractObject
1010
attr_accessor :objectish, :size, :type, :mode
11-
12-
@base = nil
13-
@contents = nil
14-
@size = nil
15-
@sha = nil
1611

1712
def initialize(base, objectish)
1813
@base = base
1914
@objectish = objectish.to_s
15+
@contents = nil
16+
@trees = nil
17+
@size = nil
18+
@sha = nil
2019
end
2120

2221
def sha
@@ -147,14 +146,13 @@ def check_tree
147146

148147
class Commit < AbstractObject
149148

150-
@tree = nil
151-
@parents = nil
152-
@author = nil
153-
@committer = nil
154-
@message = nil
155-
156149
def initialize(base, sha, init = nil)
157150
super(base, sha)
151+
@tree = nil
152+
@parents = nil
153+
@author = nil
154+
@committer = nil
155+
@message = nil
158156
if init
159157
set_commit(init)
160158
end
@@ -272,4 +270,4 @@ def self.new(base, objectish, type = nil, is_tag = false)
272270
end
273271

274272
end
275-
end
273+
end

0 commit comments

Comments
 (0)