[v2] git-diff.txt: document return code of `--no-index`
diff mbox series

Message ID ed9f16c30a0f3852abaf0053d8c2b4a0ecd12f01.1572367897.git.liu.denton@gmail.com
State New
Headers show
Series
  • [v2] git-diff.txt: document return code of `--no-index`
Related show

Commit Message

Denton Liu Oct. 29, 2019, 4:54 p.m. UTC
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(-)

Comments

Phillip Wood Oct. 30, 2019, 10:11 a.m. UTC | #1
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>...]::
>   
>
Johannes Schindelin Oct. 30, 2019, 10:02 p.m. UTC | #2
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 Oct. 30, 2019, 10:12 p.m. UTC | #3
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

Patch
diff mbox series

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