diff mbox series

git-diff.txt: document return code of `--no-index`

Message ID 3f6d132663cacde01df68bfe88c6ef108cf6cf74.1572337045.git.liu.denton@gmail.com (mailing list archive)
State New, archived
Headers show
Series git-diff.txt: document return code of `--no-index` | expand

Commit Message

Denton Liu Oct. 29, 2019, 8:19 a.m. UTC
According to the end of diff_no_index(),

	/*
	 * The return code for --no-index imitates diff(1):
	 * 0 = no changes, 1 = changes, else error
	 */
	return diff_result_code(&revs->diffopt, 0);

However, this is not properly documented in git-diff.txt.

Shamelessly steal from the `--exit-code` text and give it to the
`--no-index` documentation to explain that the return code is similar to
diff(1).

Signed-off-by: Denton Liu <liu.denton@gmail.com>
---
 Documentation/git-diff.txt | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Johannes Schindelin Oct. 29, 2019, 1:06 p.m. UTC | #1
Hi Denton,

On Tue, 29 Oct 2019, Denton Liu wrote:

> According to the end of diff_no_index(),
>
> 	/*
> 	 * The return code for --no-index imitates diff(1):
> 	 * 0 = no changes, 1 = changes, else error
> 	 */
> 	return diff_result_code(&revs->diffopt, 0);
>
> However, this is not properly documented in git-diff.txt.
>
> Shamelessly steal from the `--exit-code` text and give it to the
> `--no-index` documentation to explain that the return code is similar to
> diff(1).

Speaking of `--exit-code`...

> Signed-off-by: Denton Liu <liu.denton@gmail.com>
> ---
>  Documentation/git-diff.txt | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/git-diff.txt b/Documentation/git-diff.txt
> index 72179d993c..1e363bd200 100644
> --- a/Documentation/git-diff.txt
> +++ b/Documentation/git-diff.txt
> @@ -36,7 +36,10 @@ 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. With `--no-index`,
> +	the program exits with codes similar to diff(1). That is, it
> +	exits with 1 if there were differences and 0 means no
> +	differences.

... a shorter alternative would be to state: This implies `--exit-code`.

Ciao,
Dscho

>
>  'git diff' [<options>] --cached [<commit>] [--] [<path>...]::
>
> --
> 2.24.0.rc0.197.g0926ab8072
>
>
Junio C Hamano Oct. 30, 2019, 2:08 a.m. UTC | #2
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:

>> @@ -36,7 +36,10 @@ 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. With `--no-index`,
>> +	the program exits with codes similar to diff(1). That is, it
>> +	exits with 1 if there were differences and 0 means no
>> +	differences.
>
> ... a shorter alternative would be to state: This implies `--exit-code`.

Yup, that is great.  Short and to the point.
diff mbox series

Patch

diff --git a/Documentation/git-diff.txt b/Documentation/git-diff.txt
index 72179d993c..1e363bd200 100644
--- a/Documentation/git-diff.txt
+++ b/Documentation/git-diff.txt
@@ -36,7 +36,10 @@  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. With `--no-index`,
+	the program exits with codes similar to diff(1). That is, it
+	exits with 1 if there were differences and 0 means no
+	differences.
 
 'git diff' [<options>] --cached [<commit>] [--] [<path>...]::