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

9 messages from 2019-10-29 to 2019-11-02. Participants: Denton Liu, Johannes Schindelin, Junio C Hamano, Phillip Wood.
Thread: https://gitlist.dev/t/52146

## Denton Liu, 2019-10-29 08:19

Subject: [PATCH] git-diff.txt: document return code of `--no-index`
Message-ID: <3f6d132663cacde01df68bfe88c6ef108cf6cf74.1572337045.git.liu.denton@gmail.com>
URL: https://gitlist.dev/e/3f6d132663cacde01df68bfe88c6ef108cf6cf74.1572337045.git.liu.denton%40gmail.com

```
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(-)

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>...]::
 
-- 
2.24.0.rc0.197.g0926ab8072


```

## Johannes Schindelin, 2019-10-29 13:06

Subject: Re: [PATCH] git-diff.txt: document return code of `--no-index`
Message-ID: <nycvar.QRO.7.76.6.1910291405090.46@tvgsbejvaqbjf.bet>
URL: https://gitlist.dev/e/nycvar.QRO.7.76.6.1910291405090.46%40tvgsbejvaqbjf.bet
In-Reply-To: <3f6d132663cacde01df68bfe88c6ef108cf6cf74.1572337045.git.liu.denton@gmail.com>

```
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
>
>

```

## Denton Liu, 2019-10-29 16:54

Subject: [PATCH v2] git-diff.txt: document return code of `--no-index`
Message-ID: <ed9f16c30a0f3852abaf0053d8c2b4a0ecd12f01.1572367897.git.liu.denton@gmail.com>
URL: https://gitlist.dev/e/ed9f16c30a0f3852abaf0053d8c2b4a0ecd12f01.1572367897.git.liu.denton%40gmail.com
In-Reply-To: <3f6d132663cacde01df68bfe88c6ef108cf6cf74.1572337045.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 the review, Dscho. I guess it slipped my mind that we could
write it this way too. Oops!

 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..56b396ef81 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 `--no-exit`.
 
 'git diff' [<options>] --cached [<commit>] [--] [<path>...]::
 
-- 
2.24.0.rc0.197.g0926ab8072


```

## Junio C Hamano, 2019-10-30 02:08

Subject: Re: [PATCH] git-diff.txt: document return code of `--no-index`
Message-ID: <xmqqftjb3rz7.fsf@gitster-ct.c.googlers.com>
URL: https://gitlist.dev/e/xmqqftjb3rz7.fsf%40gitster-ct.c.googlers.com
In-Reply-To: <nycvar.QRO.7.76.6.1910291405090.46@tvgsbejvaqbjf.bet>

```
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.

```

## Phillip Wood, 2019-10-30 10:11

Subject: Re: [PATCH v2] git-diff.txt: document return code of `--no-index`
Message-ID: <4548d037-3fc5-b625-b7f9-646392392d0c@gmail.com>
URL: https://gitlist.dev/e/4548d037-3fc5-b625-b7f9-646392392d0c%40gmail.com
In-Reply-To: <ed9f16c30a0f3852abaf0053d8c2b4a0ecd12f01.1572367897.git.liu.denton@gmail.com>

```
Hi Denton

The description is good, but the patch has a typo

On 29/10/2019 16:54, Denton Liu wrote:
> 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 the review, Dscho. I guess it slipped my mind that we could
> write it this way too. Oops!
> 
>   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..56b396ef81 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 `--no-exit`.

s/--no-exit/--exit-code/

Best Wishes

Phillip

>   
>   'git diff' [<options>] --cached [<commit>] [--] [<path>...]::
>   
> 

```

## Denton Liu, 2019-10-30 18:06

Subject: [PATCH v3] git-diff.txt: document return code of `--no-index`
Message-ID: <381b2ca134ffa2f370c3882631dbaf3d591530dc.1572458622.git.liu.denton@gmail.com>
URL: https://gitlist.dev/e/381b2ca134ffa2f370c3882631dbaf3d591530dc.1572458622.git.liu.denton%40gmail.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


```

## Johannes Schindelin, 2019-10-30 22:02

Subject: Re: [PATCH v2] git-diff.txt: document return code of `--no-index`
Message-ID: <nycvar.QRO.7.76.6.1910302302060.46@tvgsbejvaqbjf.bet>
URL: https://gitlist.dev/e/nycvar.QRO.7.76.6.1910302302060.46%40tvgsbejvaqbjf.bet
In-Reply-To: <4548d037-3fc5-b625-b7f9-646392392d0c@gmail.com>

```
Hi Phillip,

On Wed, 30 Oct 2019, Phillip Wood wrote:

> Hi Denton
>
> The description is good, but the patch has a typo
>
> On 29/10/2019 16:54, Denton Liu wrote:
> > 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 the review, Dscho. I guess it slipped my mind that we could
> > write it this way too. Oops!
> >
> >   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..56b396ef81 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 `--no-exit`.
>
> s/--no-exit/--exit-code/

Oh wow. Did I really type `--no-exit` when I meant `--exit-code`? I
guess I did. What a serious Freudian.

Thanks for pointing it out.

Ciao,
Dscho

>
> Best Wishes
>
> Phillip
>
> >
> >   'git diff' [<options>] --cached [<commit>] [--] [<path>...]::
> >
> >
>

```

## Denton Liu, 2019-10-30 22:12

Subject: Re: [PATCH v2] git-diff.txt: document return code of `--no-index`
Message-ID: <20191030221245.GA44961@generichostname>
URL: https://gitlist.dev/e/20191030221245.GA44961%40generichostname
In-Reply-To: <nycvar.QRO.7.76.6.1910302302060.46@tvgsbejvaqbjf.bet>

```
Hi Dscho,

On Wed, Oct 30, 2019 at 11:02:49PM +0100, Johannes Schindelin wrote:
> > > diff --git a/Documentation/git-diff.txt b/Documentation/git-diff.txt
> > > index 72179d993c..56b396ef81 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 `--no-exit`.
> >
> > s/--no-exit/--exit-code/
> 
> Oh wow. Did I really type `--no-exit` when I meant `--exit-code`? I
> guess I did. What a serious Freudian.

Nah, you're still good. The error is all mine. I wasn't paying attention
when I rerolled the patch so I copied your text wrong. You initial
suggestion was correct.

-Denton

> 
> Thanks for pointing it out.
> 
> Ciao,
> Dscho

```

## Junio C Hamano, 2019-11-02 04:17

Subject: Re: [PATCH v3] git-diff.txt: document return code of `--no-index`
Message-ID: <xmqq4kzm6he0.fsf@gitster-ct.c.googlers.com>
URL: https://gitlist.dev/e/xmqq4kzm6he0.fsf%40gitster-ct.c.googlers.com
In-Reply-To: <381b2ca134ffa2f370c3882631dbaf3d591530dc.1572458622.git.liu.denton@gmail.com>

```
Denton Liu <liu.denton@gmail.com> writes:

> 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.

Thanks all.  I can believe that I missed that while reading v2 ;-)
I'll try to do better next time.

Queued.

```
