From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: Romain Chossart <romainchossart@gmail.com>, git@vger.kernel.org
Subject: [PATCH v2 0/7] cleaning up diff_result_code()
Date: Mon, 21 Aug 2023 16:13:58 -0400 [thread overview]
Message-ID: <20230821201358.GA2663749@coredump.intra.peff.net> (raw)
In-Reply-To: <xmqqfs4cp7dj.fsf@gitster.g>
On Mon, Aug 21, 2023 at 11:39:36AM -0700, Junio C Hamano wrote:
> Jeff King <peff@peff.net> writes:
>
> > That would make the code simpler. It does feel a bit like going in the
> > opposite direction of recent "pass errors up the stack rather than
> > dying" libification efforts. I think that's OK for the builtin_* helpers
> > in diff.c, which are just serving the diff porcelain. But things like
> > run_diff_files(), while pretty big operations, are something we might
> > call as small part of another operation (like git-describe).
>
> True, for things in diff-lib.c we likely would want to go in the
> opposite "return an error to be handled by the caller" route.
After poking at it a bit, I think it actually is OK to drop the return
codes here. There are some immediate benefits, and I'm not sure it
actually hampers libification that much; see patch 5 for my reasoning.
So here's what I came up with.
[1/7]: diff: spell DIFF_INDEX_CACHED out when calling run_diff_index()
Your patch verbatim, since there's tons of textual conflicts
otherwise.
[2/7]: diff-files: avoid negative exit value
A bonus fix that I noticed. It's the same problem as found
elsewhere, but using a different code path, so it seemed easiest to
fix on its own.
[3/7]: diff: show usage for unknown builtin_diff_files() options
This directly fixes the bug found by Romain (but in a different way
than v1).
[4/7]: diff: die when failing to read index in git-diff builtin
Obvious cleanups.
[5/7]: diff: drop useless return from run_diff_{files,index} functions
Possibly controversial cleanups. ;)
[6/7]: diff: drop useless return values in git-diff helpers
[7/7]: diff: drop useless "status" parameter from diff_result_code()
And then these are the payoff cleanups enabled by patch 5.
add-interactive.c | 2 +-
builtin/add.c | 3 +-
builtin/am.c | 4 +-
builtin/describe.c | 6 +--
builtin/diff-files.c | 12 ++----
builtin/diff-index.c | 4 +-
builtin/diff-tree.c | 2 +-
builtin/diff.c | 79 +++++++++++++++++--------------------
builtin/log.c | 2 +-
builtin/stash.c | 16 +++-----
builtin/submodule--helper.c | 7 ++--
diff-lib.c | 8 ++--
diff-no-index.c | 2 +-
diff.c | 6 +--
diff.h | 6 +--
t/t4017-diff-retval.sh | 5 +++
wt-status.c | 12 +++---
17 files changed, 81 insertions(+), 95 deletions(-)
No range-diff since it's effectively a brand-new series.
BTW, I know you were looking at --exit-code bugs recently in another
series. But I think this should all be orthogonal (both semantically
and textually). I'll try to give another review on that series, as well.
-Peff
next prev parent reply other threads:[~2023-08-21 20:14 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 ` Jeff King [this message]
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
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=20230821201358.GA2663749@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).