Thread (1 message) 1 message, 1 author, 2020-06-17

Re: [PATCH] builtin/diff: fix incorrect comment

From: Junio C Hamano <hidden>
Date: 2020-06-17 18:07:24

Denton Liu [off-list ref] writes:
A comment in cmd_diff() states that if one tree-ish and no blobs are
provided, it would provide a diff between the tree and the cache. This
is incorrect because a diff happens between the tree-ish and the working
tree. Remove the `--cached` in the comment so that the correct behavior
is shown.
Perhaps "diff-index [--cached]" is more appropriate, then?  After
all, "git diff --cached HEAD" would be N=1 M=0 case, no?
quoted hunk
Signed-off-by: Denton Liu <redacted>
---
 builtin/diff.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/builtin/diff.c b/builtin/diff.c
index 8537b17bd5..1ebab58c55 100644
--- a/builtin/diff.c
+++ b/builtin/diff.c
@@ -276,7 +276,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
 	 *	compare a blob with a working tree file.
 	 *
 	 * N=1, M=0:
-	 *      tree vs cache (diff-index --cached)
+	 *      tree vs files (diff-index)
 	 *
 	 * N=2, M=0:
 	 *      tree vs tree (diff-tree)
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help