Skip to content

Commit a9d7689

Browse files
Denton-Lgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent af6b65d commit a9d7689

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

builtin/diff.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,18 +266,30 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
266266

267267
/*
268268
* 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.
270271
*
271272
* 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+
*
273278
* N=0, M=2:
274279
* compare two random blobs. P must be zero.
280+
*
275281
* 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)
277286
*
278287
* N=1, M=0:
279288
* tree vs cache (diff-index --cached)
280289
*
290+
* N=1, M=0, --cached:
291+
* tree vs files (diff-index)
292+
*
281293
* N=2, M=0:
282294
* tree vs tree (diff-tree)
283295
*

0 commit comments

Comments
 (0)