git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: Tim Henigan <tim.henigan@gmail.com>, git@vger.kernel.org
Subject: Re: [PATCH] diff: exit(1) if 'diff --quiet <repo file> <external file>' finds changes
Date: Fri, 15 Jun 2012 16:24:41 -0400	[thread overview]
Message-ID: <20120615202441.GA12163@sigill.intra.peff.net> (raw)
In-Reply-To: <7vmx449w3j.fsf@alter.siamese.dyndns.org>

On Fri, Jun 15, 2012 at 01:08:32PM -0700, Junio C Hamano wrote:

> Tim Henigan <tim.henigan@gmail.com> writes:
> 
> >>> @@ -273,5 +273,6 @@ void diff_no_index(struct rev_info *revs,
> >>>        * The return code for --no-index imitates diff(1):
> >>>        * 0 = no changes, 1 = changes, else error
> >>>        */
> >>> -     exit(revs->diffopt.found_changes);
> >>> +     result = !!diff_result_code(&revs->diffopt, 0);
> >>> +     exit(result);
> >
> > I assume the '!!' before 'diff_result_code' is a typo.
> 
> Not a typo.  I meant to use that idiom to turn 0 or not into
> boolean, as diff_result_code() can return values other than 0 or 1.

I wonder if that is a good idea, though. AFAICT, diff_result_code will
only return a different exit code if "--check" is used. If we pass along
the exit code fully, then:

  1. If --check is not used, we will be diff(1)-compatible.

  2. If --check is used, then we will not be compatible with diff(1) in
     our exit code. But diff(1) does not have --check in the first
     place, so there is no point in us trying to be a drop-in
     replacement.

-Peff

  reply	other threads:[~2012-06-15 20:24 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-15 17:31 [PATCH] diff: exit(1) if 'diff --quiet <repo file> <external file>' finds changes Tim Henigan
2012-06-15 18:40 ` Jeff King
2012-06-15 19:13   ` Jeff King
2012-06-15 18:45 ` Junio C Hamano
2012-06-15 19:37   ` Jeff King
2012-06-15 19:56     ` Tim Henigan
2012-06-15 20:08       ` Junio C Hamano
2012-06-15 20:24         ` Jeff King [this message]
2012-06-15 20:44           ` Junio C Hamano
2012-06-15 20:10       ` Junio C Hamano
2012-06-18 17:51         ` Tim Henigan
2012-06-18 18:00           ` Junio C Hamano

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

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

  git send-email \
    --in-reply-to=20120615202441.GA12163@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=tim.henigan@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.
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).