0

I'm trying to do a very simple thing: Read a diff from a git repo via the ruby gem Grit. I'm creating a file and adding the line "This is me changing the first file". Now I do this to get the diff:

r = Grit::Repo.new("myrepo")
c = r.commits.first
d = r.commit_diff(c.id).first
puts d.first.diff

The output of this is:

--- a/First-File.asciidoc
+++ b/First-File.asciidoc
@@ -1,2 +1 @@
-This is me changing the first file

See that minus in front of the added line? Why would a commit_diff show in reverse? I know that git reverses the diff if I reverse the commit shas, but this is a Grit library call that only gives the commit diff?

Any clues?

Ronze
  • 1,544
  • 2
  • 18
  • 33

1 Answers1

0

Let me answer that question. The commit shows up in correct form, if you do this insteas:

r = Grit::Repo.new("myrepo")
c = r.commits.first
d = c.diffs.first
puts d.first.diff

Not sure what the difference would be between Commit.diff and Repo.commit_diff.

Ronze
  • 1,544
  • 2
  • 18
  • 33