aboutsummaryrefslogtreecommitdiff
path: root/t/t4013/diff.diff_--cached_--_file0
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2011-02-03 13:23:34 +0700
committerJunio C Hamano <gitster@pobox.com>2011-02-07 15:04:30 -0800
commita2b7a3b3a966c5801efe968d4b5656fa5a885409 (patch)
tree10fa9f1407f71ccec95459533dddf9c956f3559d /t/t4013/diff.diff_--cached_--_file0
parent2e9c8789b7b0d4d3cd2f951e1694387686e2d740 (diff)
downloadgit-a2b7a3b3a966c5801efe968d4b5656fa5a885409.tar.gz
git-a2b7a3b3a966c5801efe968d4b5656fa5a885409.tar.xz
diff: support --cached on unborn branches
"git diff --cached" (without revision) used to mean "git diff --cached HEAD" (i.e. the user was too lazy to type HEAD). This "correctly" failed when there was no commit yet. But was that correctness useful? This patch changes the definition of what particular command means. It is a request to show what _would_ be committed without further "git add". The internal implementation is the same "git diff --cached HEAD" when HEAD exists, but when there is no commit yet, it compares the index with an empty tree object to achieve the desired result. Signed-off-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t4013/diff.diff_--cached_--_file0')
-rw-r--r--t/t4013/diff.diff_--cached_--_file015
1 files changed, 15 insertions, 0 deletions
diff --git a/t/t4013/diff.diff_--cached_--_file0 b/t/t4013/diff.diff_--cached_--_file0
new file mode 100644
index 000000000..b9bb858a0
--- /dev/null
+++ b/t/t4013/diff.diff_--cached_--_file0
@@ -0,0 +1,15 @@
+diff --git a/file0 b/file0
+new file mode 100644
+index 0000000..10a8a9f
+--- /dev/null
++++ b/file0
+@@ -0,0 +1,9 @@
++1
++2
++3
++4
++5
++6
++A
++B
++C