Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jgit-dev] Creating the equivalent of "git diff"

That sounds like what I'm looking to do. Is it correct to use CanonicalTreeParser the way I did to accomplish this?

On Sep 16, 2014 1:43 PM, "Dave Borowitz" <dborowitz@xxxxxxxxxx> wrote:
My mistake, "git diff" diffs the work tree against the index. I don't have it in front of me but I'll bet if you look at the implementation, that's what pgm.Diff is doing :)

On Mon, Sep 15, 2014 at 10:16 PM, Robin Stocker <robin@xxxxxxxxx> wrote:
Dave Borowitz wrote:
> "git diff" is the same as "git diff HEAD".

That's not correct in general:

$ mkdir git-diff-test && cd git-diff-test && git init -q
$ echo "a" > file.txt
$ git add file.txt
$ git commit -qm "Initial"
$ echo "b" >> file.txt
$ git add file.txt
$ echo "c" >> file.txt
$ git diff
diff --git a/file.txt b/file.txt
index 422c2b7..de98044 100644
--- a/file.txt
+++ b/file.txt
@@ -1,2 +1,3 @@
 a
 b
+c
$ git diff HEAD
diff --git a/file.txt b/file.txt
index 7898192..de98044 100644
--- a/file.txt
+++ b/file.txt
@@ -1 +1,3 @@
 a
+b
+c


It's only the same if there are no changes between index and HEAD.

Having said that, I don't know which one Zach actually wants :).

Regards,
  Robin


Back to the top