Skip to content

Commit 45b085a

Browse files
Merge branch 'diff_fix_current_vs_head' of https://github.com/francisluong/ruby-git into francisluong-diff_fix_current_vs_head
2 parents 50d80b6 + c7b31d1 commit 45b085a

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

lib/git/diff.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ class Diff
66

77
def initialize(base, from = nil, to = nil)
88
@base = base
9-
@from = from.to_s
10-
@to = to.to_s
9+
@from = from && from.to_s
10+
@to = to && to.to_s
1111

1212
@path = nil
1313
@full_diff = nil

tests/units/test_diff.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ def setup
1414
# assert(1, d.size)
1515
#end
1616

17+
def test_diff_current_vs_head
18+
#test git diff without specifying source/destination commits
19+
update_file(File.join(@wdir,"example.txt"),"FRANCO")
20+
d = @git.diff
21+
patch = d.patch
22+
assert(patch.match(/\+FRANCO/))
23+
end
24+
1725
def test_diff_tags
1826
d = @git.diff('gitsearch1', 'v2.5')
1927
assert_equal(3, d.size)

0 commit comments

Comments
 (0)