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

[PATCH v3] git-diff.txt: document return code of `--no-index`

From
Denton Liu <liu.denton@gmail.com>
Date
Oct 30, 2019, 18:06 UTC
Message-ID
<381b2ca134ffa2f370c3882631dbaf3d591530dc.1572458622.git.liu.denton@gmail.com>
In-Reply-To
<ed9f16c30a0f3852abaf0053d8c2b4a0ecd12f01.1572367897.git.liu.denton@gmail.com>
Within diff_no_index(), we have the following:
	revs->diffopt.flags.exit_with_status = 1;
	...
	/*
	 * The return code for --no-index imitates diff(1):
	 * 0 = no changes, 1 = changes, else error
	 */
	return diff_result_code(&revs->diffopt, 0);

Which means when `git diff` is run in `--no-index` mode, `--exit-code` is implied. However, the documentation for this is missing in git-diff.txt.

Add a note about how `--exit-code` is implied in the `--no-index` documentation to cover this documentation blindspot.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
---
Thanks for catching the typo, Phillip. I can't believe I missed that in
such a simple patch.
Range-diff against v2:
1:  ed9f16c30a ! 1:  381b2ca134 git-diff.txt: document return code of `--no-index`
    @@ Documentation/git-diff.txt: two blob objects, or changes between two files on di
      	at least one of the paths points outside the working tree,
      	or when running the command outside a working tree
     -	controlled by Git.
    -+	controlled by Git. This form implies `--no-exit`.
    ++	controlled by Git. This form implies `--exit-code`.
      
      'git diff' [<options>] --cached [<commit>] [--] [<path>...]::
      
 Documentation/git-diff.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Documentation/git-diff.txt b/Documentation/git-diff.txt
index 72179d993c..37781cf175 100644
--- a/Documentation/git-diff.txt
+++ b/Documentation/git-diff.txt
@@ -36,7 +36,7 @@ two blob objects, or changes between two files on disk.
 	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.
+	controlled by Git. This form implies `--exit-code`.
 
 'git diff' [<options>] --cached [<commit>] [--] [<path>...]::
 
-- 
2.24.0.rc1.251.gd52a1e41a1
Previous: Denton LiuNext: Junio C Hamano
Message 8 of 9 in “git-diff.txt: document return code of `--no-index`”
  1. git-diff.txt: document return code of `--no-index`Denton Liu, Oct 29, 2019
  2. Johannes SchindelinOct 29, 2019
  3. Junio C HamanoOct 30, 2019
  4. git-diff.txt: document return code of `--no-index`Denton Liu, Oct 29, 2019
  5. Phillip WoodOct 30, 2019
  6. Johannes SchindelinOct 30, 2019
  7. Denton LiuOct 30, 2019
  8. git-diff.txt: document return code of `--no-index`Denton Liu, Oct 30, 2019
  9. Junio C HamanoNov 2, 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.