git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] git-diff.txt: document return code of `--no-index`
@ 2019-10-29  8:19 Denton Liu
  2019-10-29 13:06 ` Johannes Schindelin
  2019-10-29 16:54 ` [PATCH v2] " Denton Liu
  0 siblings, 2 replies; 9+ messages in thread
From: Denton Liu @ 2019-10-29  8:19 UTC (permalink / raw)
  To: Git Mailing List

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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] git-diff.txt: document return code of `--no-index`
  2019-10-29  8:19 [PATCH] git-diff.txt: document return code of `--no-index` Denton Liu
@ 2019-10-29 13:06 ` Johannes Schindelin
  2019-10-30  2:08   ` Junio C Hamano
  2019-10-29 16:54 ` [PATCH v2] " Denton Liu
  1 sibling, 1 reply; 9+ messages in thread
From: Johannes Schindelin @ 2019-10-29 13:06 UTC (permalink / raw)
  To: Denton Liu; +Cc: Git Mailing List

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v2] git-diff.txt: document return code of `--no-index`
  2019-10-29  8:19 [PATCH] git-diff.txt: document return code of `--no-index` Denton Liu
  2019-10-29 13:06 ` Johannes Schindelin
@ 2019-10-29 16:54 ` Denton Liu
  2019-10-30 10:11   ` Phillip Wood
  2019-10-30 18:06   ` [PATCH v3] " Denton Liu
  1 sibling, 2 replies; 9+ messages in thread
From: Denton Liu @ 2019-10-29 16:54 UTC (permalink / raw)
  To: Git Mailing List; +Cc: Johannes Schindelin

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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] git-diff.txt: document return code of `--no-index`
  2019-10-29 13:06 ` Johannes Schindelin
@ 2019-10-30  2:08   ` Junio C Hamano
  0 siblings, 0 replies; 9+ messages in thread
From: Junio C Hamano @ 2019-10-30  2:08 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: Denton Liu, Git Mailing List

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.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] git-diff.txt: document return code of `--no-index`
  2019-10-29 16:54 ` [PATCH v2] " Denton Liu
@ 2019-10-30 10:11   ` Phillip Wood
  2019-10-30 22:02     ` Johannes Schindelin
  2019-10-30 18:06   ` [PATCH v3] " Denton Liu
  1 sibling, 1 reply; 9+ messages in thread
From: Phillip Wood @ 2019-10-30 10:11 UTC (permalink / raw)
  To: Denton Liu, Git Mailing List; +Cc: Johannes Schindelin, Junio C Hamano

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v3] git-diff.txt: document return code of `--no-index`
  2019-10-29 16:54 ` [PATCH v2] " Denton Liu
  2019-10-30 10:11   ` Phillip Wood
@ 2019-10-30 18:06   ` Denton Liu
  2019-11-02  4:17     ` Junio C Hamano
  1 sibling, 1 reply; 9+ messages in thread
From: Denton Liu @ 2019-10-30 18:06 UTC (permalink / raw)
  To: Git Mailing List; +Cc: Johannes Schindelin, Phillip Wood

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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] git-diff.txt: document return code of `--no-index`
  2019-10-30 10:11   ` Phillip Wood
@ 2019-10-30 22:02     ` Johannes Schindelin
  2019-10-30 22:12       ` Denton Liu
  0 siblings, 1 reply; 9+ messages in thread
From: Johannes Schindelin @ 2019-10-30 22:02 UTC (permalink / raw)
  To: phillip.wood; +Cc: Denton Liu, Git Mailing List, Junio C Hamano

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] git-diff.txt: document return code of `--no-index`
  2019-10-30 22:02     ` Johannes Schindelin
@ 2019-10-30 22:12       ` Denton Liu
  0 siblings, 0 replies; 9+ messages in thread
From: Denton Liu @ 2019-10-30 22:12 UTC (permalink / raw)
  To: Johannes Schindelin, gg; +Cc: phillip.wood, Git Mailing List, Junio C Hamano

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v3] git-diff.txt: document return code of `--no-index`
  2019-10-30 18:06   ` [PATCH v3] " Denton Liu
@ 2019-11-02  4:17     ` Junio C Hamano
  0 siblings, 0 replies; 9+ messages in thread
From: Junio C Hamano @ 2019-11-02  4:17 UTC (permalink / raw)
  To: Denton Liu; +Cc: Git Mailing List, Johannes Schindelin, Phillip Wood

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.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2019-11-02  4:18 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-29  8:19 [PATCH] git-diff.txt: document return code of `--no-index` Denton Liu
2019-10-29 13:06 ` Johannes Schindelin
2019-10-30  2:08   ` Junio C Hamano
2019-10-29 16:54 ` [PATCH v2] " Denton Liu
2019-10-30 10:11   ` Phillip Wood
2019-10-30 22:02     ` Johannes Schindelin
2019-10-30 22:12       ` Denton Liu
2019-10-30 18:06   ` [PATCH v3] " Denton Liu
2019-11-02  4:17     ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).