Skip to content

Commit de1db54

Browse files
committed
Make the first commit its own parent (issues #25 & #159)
1 parent e63bc47 commit de1db54

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

lib/git/object.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def gtree
182182
end
183183

184184
def parent
185-
parents.first
185+
parents.first || self
186186
end
187187

188188
# array of all parent commits

tests/units/test_object.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ def test_commit
4141
o = @git.gcommit('test_object')
4242
assert(o.is_a?(Git::Object::Commit))
4343
assert(o.commit?)
44+
45+
o = @git.gcommit('545ffc79786f268524c35e1e05b1770c7c74faf1')
46+
assert('545ffc79786f268524c35e1e05b1770c7c74faf1', o.parent.sha)
4447
end
4548

4649
def test_commit_contents

0 commit comments

Comments
 (0)