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

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