From a9d7689cd405883849fc5bc5427812654d59394f Mon Sep 17 00:00:00 2001 From: Denton Liu Date: Thu, 18 Jun 2020 06:43:34 -0400 Subject: 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 Signed-off-by: Junio C Hamano diff --git a/builtin/diff.c b/builtin/diff.c index 42ac803..bdae4d6 100644 --- a/builtin/diff.c +++ b/builtin/diff.c @@ -266,18 +266,30 @@ int cmd_diff(int argc, const char **argv, const char *prefix) /* * We could get N tree-ish in the rev.pending_objects list. - * Also there could be M blobs there, and P pathspecs. + * Also there could be M blobs there, and P pathspecs. --cached may + * also be present. * * N=0, M=0: - * cache vs files (diff-files) + * cache vs files (diff-files) + * + * N=0, M=0, --cached: + * HEAD vs cache (diff-index --cached) + * * N=0, M=2: * compare two random blobs. P must be zero. + * * N=0, M=1, P=1: - * compare a blob with a working tree file. + * compare a blob with a working tree file. + * + * N=1, M=0: + * tree vs files (diff-index) * * N=1, M=0: * tree vs cache (diff-index --cached) * + * N=1, M=0, --cached: + * tree vs files (diff-index) + * * N=2, M=0: * tree vs tree (diff-tree) * -- cgit v0.10.2-6-g49f6 From c592fd4c83021b4f098012b3307298fff923c6e7 Mon Sep 17 00:00:00 2001 From: Denton Liu Date: Tue, 23 Jun 2020 05:19:49 -0400 Subject: builtin/diff: fix botched update of usage comment In the previous commit, an attempt was made to correct the "N=1, M=0" case. However, the fix was botched and it introduced two half-correct sections by mistake. Combine these half-correct sections into one fully correct section. Signed-off-by: Denton Liu Signed-off-by: Junio C Hamano diff --git a/builtin/diff.c b/builtin/diff.c index bdae4d6..cdfb58d 100644 --- a/builtin/diff.c +++ b/builtin/diff.c @@ -284,11 +284,8 @@ int cmd_diff(int argc, const char **argv, const char *prefix) * N=1, M=0: * tree vs files (diff-index) * - * N=1, M=0: - * tree vs cache (diff-index --cached) - * * N=1, M=0, --cached: - * tree vs files (diff-index) + * tree vs cache (diff-index --cached) * * N=2, M=0: * tree vs tree (diff-tree) -- cgit v0.10.2-6-g49f6