builtin/diff: update usage comment
A comment in cmd_diff() states that if one tree-ish and no blobs are provided, (the "N=1, M=0" case), it will 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. Add a new section describing the "N=1, M=0, --cached" behavior. Next, describe the "N=0, M=0, --cached" case, similar to the above since it is undocumented. Finally, fix some spacing issues. Add spaces between each section for consistency and readability. Also, change tabs within the comment into spaces. Signed-off-by: Denton Liu <liu.denton@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Denton Liu committed
Jun 18, 2020 at 06:43 UTC
a9d7689cd405883849fc5bc5427812654d59394f
1 file changed
+15
-3
builtin/diff.c
+15
-3
@@ -266,18 +266,30 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
266
267
/*
268
* We could get N tree-ish in the rev.pending_objects list.
269
- * Also there could be M blobs there, and P pathspecs.
269
+ * Also there could be M blobs there, and P pathspecs. --cached may
270
+ * also be present.
271
*
272
* N=0, M=0:
272
- * cache vs files (diff-files)
273
+ * cache vs files (diff-files)
274
+ *
275
+ * N=0, M=0, --cached:
276
+ * HEAD vs cache (diff-index --cached)
277
+ *
278
* N=0, M=2:
279
* compare two random blobs. P must be zero.
280
+ *
281
* N=0, M=1, P=1:
276
- * compare a blob with a working tree file.
282
+ * compare a blob with a working tree file.
283
+ *
284
+ * N=1, M=0:
285
+ * tree vs files (diff-index)
286
*
287
* N=1, M=0:
288
* tree vs cache (diff-index --cached)
289
*
290
+ * N=1, M=0, --cached:
291
+ * tree vs files (diff-index)
292
+ *
293
* N=2, M=0:
294
* tree vs tree (diff-tree)
295
*