git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Y5 via GitGitGadget <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Y5 <y5c4l3@proton.me>
Subject: Re: [PATCH] diff: setup pager only before diff contents truly ready
Date: Sat, 19 Oct 2024 17:19:38 -0400	[thread overview]
Message-ID: <20241019211938.GA589728@coredump.intra.peff.net> (raw)
In-Reply-To: <pull.1817.git.git.1729370390416.gitgitgadget@gmail.com>

On Sat, Oct 19, 2024 at 08:39:50PM +0000, Y5 via GitGitGadget wrote:

> git-diff setups pager at an early stage in cmd_diff; running diff with
> invalid options like git diff --invalid will unexpectedly starts a
> pager, which causes behavior inconsistency.

I do think the outcome is a little nicer for the user, but I'd hesitate
to call it more inconsistent. Most of the rest of Git is setting up the
pager in git.c, before we even call into the builtin. So any early
errors will likewise go to the pager. E.g., try "git log --foo".

So I dunno. I'm not strictly opposed to making things nicer when we can
do so easily.  But the endgame of this is probably getting rid of
USE_PAGER entirely and asking each builtin to decide when to commit to
using the pager (presumably after option parsing).

And even then, it wouldn't apply to commands implemented as an external
process. And of course we can still die(), etc, after starting the
pager. So it would never be totally consistent.

> Signed-off-by: y5c4l3 <y5c4l3@proton.me>

We usually ask for something approaching a legal name, as this sign-off
is supposed to be certifying the DCO (see the "dco" section in
Documentation/SubmittingPatches).

>  builtin/diff.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)

The patch itself looks plausibly correct. The biggest regression risk
would be missing a spot that needed a new setup_diff_pager() call, and I
suspect we don't have good test coverage here. But going top-down from
builtin_diff(), I don't see any paths you missed.

-Peff

  parent reply	other threads:[~2024-10-19 21:26 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-19 20:39 [PATCH] diff: setup pager only before diff contents truly ready Y5 via GitGitGadget
2024-10-19 20:57 ` Kristoffer Haugsbakk
2024-10-21  0:17   ` Philip Yung
2024-10-19 21:19 ` Jeff King [this message]
2024-10-21  0:11   ` Philip Yung
2024-10-21 19:00     ` Jeff King
2024-10-21 19:38       ` Taylor Blau
2024-11-18  0:55         ` Junio C Hamano
2024-11-25 11:31           ` Jeff King
2024-12-03  5:33             ` Junio C Hamano
2024-12-03 21:24               ` Jeff King
2024-12-04  0:18                 ` 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=20241019211938.GA589728@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=y5c4l3@proton.me \
    /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).