From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: Romain Chossart <romainchossart@gmail.com>, git@vger.kernel.org
Subject: Re: [PATCH v2 7/7] diff: drop useless "status" parameter from diff_result_code()
Date: Wed, 23 Aug 2023 15:00:22 -0400 [thread overview]
Message-ID: <20230823190022.GA2355007@coredump.intra.peff.net> (raw)
In-Reply-To: <xmqq350air6e.fsf@gitster.g>
On Tue, Aug 22, 2023 at 04:38:17PM -0700, Junio C Hamano wrote:
> > This function also takes a "status" parameter, which seems at first
> > glance that it could be used to propagate an error encountered when
> > computing the diff. But it doesn't work that way:
> >
> > - negative values are passed through as-is, but are not appropriate as
> > program exit codes
> >
> > - when --exit-code or --check is in effect, we _ignore_ the passed-in
> > status completely. So a failed diff which did not have a chance to
> > set opts.found_changes would erroneously report "success, no
> > changes" instead of propagating the error.
> >
> > After recent cleanups, neither of these bugs is possible to trigger, as
>
> Here "after recent cleanups" refers to the changes to make them
> die() upon seeing an error, instead of using it to call this
> function with non-zero in the status parameter? At least, they were
> signaling errors correctly when --exit-code is not in use, but now
> all the callers are responsible for exiting with non-zero status to
> signal an error even when --exit-code is *not* used.
Sort of. Prior to this series, callers were responsible for ferrying
exit codes to diff_result_code(), which mis-handled them (a little for
the path without --exit-code, and badly with it). Now they are
responsible for handling the errors themselves. I'd say that is not much
more work than passing them along, and provides better outcomes (they
can produce more useful error messages, or die() as appropriate).
But what I really meant with "after recent cleanups" was just that
nobody is even bothering to pass anything but 0 to diff_result_code().
Which was already true before the series for every code path except the
few index/argument parsing paths in builtin/diff.c, and after the
cleanups is entirely true.
-Peff
prev parent reply other threads:[~2023-08-23 19:01 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-20 19:52 "git diff --no-pager --exit-code" errors out but returns zero exit code Romain Chossart
2023-08-21 0:35 ` [PATCH] diff: handle negative status in diff_result_code() Jeff King
2023-08-21 15:56 ` Junio C Hamano
2023-08-21 16:21 ` [PATCH] diff: spell DIFF_INDEX_CACHED out when calling run_diff_index() Junio C Hamano
2023-08-21 18:36 ` Jeff King
2023-08-21 22:08 ` Junio C Hamano
2023-08-21 18:09 ` [PATCH] diff: handle negative status in diff_result_code() Jeff King
2023-08-21 18:39 ` Junio C Hamano
2023-08-21 20:13 ` [PATCH v2 0/7] cleaning up diff_result_code() Jeff King
2023-08-21 20:14 ` [PATCH v2 1/7] diff: spell DIFF_INDEX_CACHED out when calling run_diff_index() Jeff King
2023-08-21 20:15 ` [PATCH v2 2/7] diff-files: avoid negative exit value Jeff King
2023-08-21 20:16 ` [PATCH v2 3/7] diff: show usage for unknown builtin_diff_files() options Jeff King
2023-08-21 20:17 ` [PATCH v2 4/7] diff: die when failing to read index in git-diff builtin Jeff King
2023-08-22 23:27 ` Junio C Hamano
2023-08-21 20:18 ` [PATCH v2 5/7] diff: drop useless return from run_diff_{files,index} functions Jeff King
2023-08-21 20:19 ` [PATCH v2 6/7] diff: drop useless return values in git-diff helpers Jeff King
2023-08-21 20:20 ` [PATCH v2 7/7] diff: drop useless "status" parameter from diff_result_code() Jeff King
2023-08-22 23:38 ` Junio C Hamano
2023-08-23 19:00 ` Jeff King [this message]
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=20230823190022.GA2355007@coredump.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=romainchossart@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).