comparing 2 commits in rugged
Asked Answered
T

1

4

I didn't find any documentation on getting the difference between 2 files in rugged. I used the below code to commit a file using rugged

@repo=Rugged::Repository.new($reponame)
@[email protected]('D:\Ruby\MyGitRepo\file1.txt','blob')
puts @sha
commit = @repo.lookup(@sha)

how can see the difference between the 2 commits of the same object in rugged?

Trustworthy answered 17/1, 2013 at 18:50 Comment(0)
B
5

The way to compare two commits in git relies on a diffing process.

brianmario recently wrapped the diffing iterator feature of libgit2. Beware that this feature is not merged yet.

Below a high level example of its future usage.

r = Rugged::Repository.new('.')
diff = r.diff(commit1, commit2)

diff.deltas.each do |delta|
  # ...
  delta.hunks.each do |hunk|
    # ...
    hunk.lines.each do |line|
      # ...
    end
  end
end

See this pull request for more information about proposed diff implementation and usage.

Brogle answered 18/1, 2013 at 7:39 Comment(1)
thanks.. I did came across this post once I posted the question here.. trying it out..Trustworthy

© 2022 - 2024 — McMap. All rights reserved.