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

"git diff --no-index" Implies "--exit-code"

From
JFJohn Ferreira <jferreira@nvidia.com>
Date
Nov 27, 2019, 04:03 UTC
Message-ID
<MN2PR12MB289677B16DBF67772627B595DE440@MN2PR12MB2896.namprd12.prod.outlook.com>

I suspect this may be a bug: Because I am not specifying the "--exit-code" flag, I expect "git diff --no-index" to have the same exit code style as git diff. But it does not. See comment in source linked below. Or, if this is intended, this side effect should be noted in the documentation for --no-index.

https://git-scm.com/docs/git-diff --exit-code Make the program exit with codes similar to diff(1). That is, it exits with 1 if there were differences and 0 means no differences.

git diff [<options>] --no-index [--] <path> <path> This form is to compare the given two paths on the filesystem. You can omit the --no-index option when running the command in a working tree controlled by Git and at least one of the paths points outside the working tree, or when running the command outside a working tree controlled by Git.

https://github.com/git/git/blob/83232e38648b51abbcbdb56c94632b6906cc85a6/diff-no-index.c#L307
/*
 * The return code for --no-index imitates diff(1):
 * 0 = no changes, 1 = changes, else error
*/
-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain
confidential information.  Any unauthorized review, use, disclosure or distribution
is prohibited.  If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------
Next: Denton Liu
Message 1 of 2 in “"git diff --no-index" Implies "--exit-code"”
  1. John FerreiraNov 27, 2019
  2. Denton LiuNov 27, 2019

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.