git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* "git diff --no-index" Implies "--exit-code"
@ 2019-11-27  4:03 John Ferreira
  2019-11-27  8:46 ` Denton Liu
  0 siblings, 1 reply; 2+ messages in thread
From: John Ferreira @ 2019-11-27  4:03 UTC (permalink / raw)
  To: git@vger.kernel.org

I suspect this may be a bug:
Because I am not specifying the "--exit-code" flag,  I expect "git diff --no-index" to have the same exit code style as git diff.
But it does not.  
See comment in source linked below.  
Or, if this is intended, this side effect should be noted in the documentation for --no-index.

https://git-scm.com/docs/git-diff
--exit-code
Make the program exit with codes similar to diff(1). That is, it exits with 1 if there were differences and 0 means no differences.

git diff [<options>] --no-index [--] <path> <path>
This form is to compare the given two paths on the filesystem. You can omit the --no-index option when 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.


https://github.com/git/git/blob/83232e38648b51abbcbdb56c94632b6906cc85a6/diff-no-index.c#L307
/*
 * The return code for --no-index imitates diff(1):
 * 0 = no changes, 1 = changes, else error
*/
-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain
confidential information.  Any unauthorized review, use, disclosure or distribution
is prohibited.  If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------

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

* Re: "git diff --no-index" Implies "--exit-code"
  2019-11-27  4:03 "git diff --no-index" Implies "--exit-code" John Ferreira
@ 2019-11-27  8:46 ` Denton Liu
  0 siblings, 0 replies; 2+ messages in thread
From: Denton Liu @ 2019-11-27  8:46 UTC (permalink / raw)
  To: John Ferreira; +Cc: git@vger.kernel.org

Hi John,

On Wed, Nov 27, 2019 at 04:03:48AM +0000, John Ferreira wrote:
> I suspect this may be a bug:
> Because I am not specifying the "--exit-code" flag,  I expect "git diff --no-index" to have the same exit code style as git diff.
> But it does not.  
> See comment in source linked below.  
> Or, if this is intended, this side effect should be noted in the documentation for --no-index.
> 
> https://git-scm.com/docs/git-diff
> --exit-code
> Make the program exit with codes similar to diff(1). That is, it exits with 1 if there were differences and 0 means no differences.
> 
> git diff [<options>] --no-index [--] <path> <path>
> This form is to compare the given two paths on the filesystem. You can omit the --no-index option when 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.
> 
> 
> https://github.com/git/git/blob/83232e38648b51abbcbdb56c94632b6906cc85a6/diff-no-index.c#L307
> /*
>  * The return code for --no-index imitates diff(1):
>  * 0 = no changes, 1 = changes, else error
> */

This is a documentation bug. It's already a known issue and there's a
fix for it already queued up in next[1].

Thanks,

Denton

[1]: https://github.com/gitster/git/commit/0115e5d929d06ad41eff83742a3e6a1e91ecc0c4

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

end of thread, other threads:[~2019-11-27  8:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-27  4:03 "git diff --no-index" Implies "--exit-code" John Ferreira
2019-11-27  8:46 ` Denton Liu

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).