Skip to content

Commit 7e073ae

Browse files
author
Louis Nyffenegger
committed
Add inverse parameter to diff_parent to be able to do diff file1 file2 and diff file2 file1
1 parent 94f389b commit 7e073ae

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lib/git/object.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,9 @@ def grep(string, path_limiter = nil, opts = {})
5353
@base.lib.grep(string, opts)
5454
end
5555

56-
def diff(objectish)
57-
Git::Diff.new(@base, @objectish, objectish)
56+
def diff(objectish,inverse)
57+
return Git::Diff.new(@base, @objectish, objectish) unless inverse
58+
Git::Diff.new(@base, objectish, @objectish)
5859
end
5960

6061
def log(count = 30)
@@ -203,8 +204,8 @@ def committer_date
203204
end
204205
alias_method :date, :committer_date
205206

206-
def diff_parent
207-
diff(parent)
207+
def diff_parent(inverse=false)
208+
diff(parent,inverse)
208209
end
209210

210211
def set_commit(data)

0 commit comments

Comments
 (0)