git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Thomas Gummerer <t.gummerer@gmail.com>
To: Alexander Mills <alexander.d.mills@gmail.com>
Cc: Jonathan Nieder <jrnieder@gmail.com>, git@vger.kernel.org
Subject: exit code in git diff-index [was: Re: concurrent access to multiple local git repos is error prone]
Date: Sun, 5 Aug 2018 20:34:06 +0100	[thread overview]
Message-ID: <20180805193406.GH2734@hank.intra.tgummerer.com> (raw)
In-Reply-To: <CA+KyZp6KXFfEKNho7njg=0tDxAk-mSMP9r9hZFFH+gZcJ8KptQ@mail.gmail.com>

On 08/05, Alexander Mills wrote:
> Also, as an aside, this seems to be a bug, but probably a known bug:
> 
> $ git diff-index  HEAD; echo $?
> 
> :100755 100755 60e5d683c1eb3e61381b1a8ec2db822b94b9faec
> 0000000000000000000000000000000000000000 M      cli/npp_check_merge.sh
> :100644 100644 35a453544de41e2227ab0afab31a396d299139e9
> 0000000000000000000000000000000000000000 M      src/find-projects.ts
> :100644 100644 c1ee7bc18e6604cbf0d16653e9366109d6ac2ec9
> 0000000000000000000000000000000000000000 M      src/tables.ts
> :100644 100644 29d9674fbb48f223f3434179d666b2aa991ad05a
> 0000000000000000000000000000000000000000 M
> src/vcs-helpers/git-helpers.ts
> 0
> 
> $ git diff-index --quiet HEAD; echo $?
> 1
> 
> different exit codes depending on whether --quiet was used. In this
> case, the exit code should be consistent.
> The bug is with the `git diff-index` command, as you can see.

This is not a bug. 'git diff-index' (and 'git diff') only give an exit
code other than 0 in the default case if something actually goes wrong
with generating the diff, which in the usual case it shouldn't.

To get an exit code from 'git diff-index' if there are differences,
you'd have to pass the '--exit-code' flag.  The '--quite' flag implies
'--exit-code', as there's not much use in 'git diff --quiet' if
there's not even an exit code showing whether there are differences or
not.

The original patch (and more importantly the reasoning why
'--exit-code' is not the default behaviour for 'git diff') can be
found at [1].

[1]: https://public-inbox.org/git/81b0412b0703131717k7106ee1cg964628f0bda2c83e@mail.gmail.com/

> -alex


  reply	other threads:[~2018-08-05 19:34 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-04 21:47 concurrent access to multiple local git repos is error prone Alexander Mills
2018-08-04 21:48 ` Alexander Mills
2018-08-05  1:46   ` Jonathan Nieder
     [not found]     ` <CA+KyZp5i0EXPJ10v+SXmHWCYvZ7=XT8K8gcka0qxCBYXq=OevA@mail.gmail.com>
2018-08-05  6:13       ` Jonathan Nieder
     [not found]         ` <CA+KyZp4Yc4_Xaw3v+BPwxi_PW75=GXmj=Re7EpsurXi2_hMc9w@mail.gmail.com>
2018-08-05  8:11           ` Jonathan Nieder
2018-08-05 19:17             ` Alexander Mills
2018-08-05 19:34               ` Thomas Gummerer [this message]
2018-08-06  7:36             ` Alexander Mills
2018-08-06  7:38               ` Alexander Mills
2018-08-06 14:32               ` Jonathan Nieder
2018-08-06 15:22               ` Duy Nguyen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180805193406.GH2734@hank.intra.tgummerer.com \
    --to=t.gummerer@gmail.com \
    --cc=alexander.d.mills@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=jrnieder@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).