git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 17, 2020, 18:07 UTC
Message-ID
<xmqqzh91va5n.fsf@gitster.c.googlers.com>
In-Reply-To
<a9aea5dbb821544eea636bc5de9fe8185bb603fb.1592219700.git.liu.denton@gmail.com>
Denton Liu <liu.denton@gmail.com> writes:
Show 5 quoted lines
> 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?

Show 18 quoted lines
> Signed-off-by: Denton Liu <liu.denton@gmail.com>
> ---
>  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)
Previous: Denton LiuNext: Denton Liu
Message 2 of 3 in “builtin/diff: fix incorrect comment”
  1. builtin/diff: fix incorrect commentDenton Liu, Jun 15, 2020
  2. Junio C HamanoJun 17, 2020
  3. builtin/diff: update usage commentDenton Liu, Jun 18, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.