Git development
 help / color / mirror / Atom feed
From: "brian m. carlson" <sandals@crustytoothpaste.net>
To: Francisco Boni <boboniboni@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: pager: consider revisiting automatic LESS=FRX with custom core.pager
Date: Sat, 19 Sep 2026 15:48:06 +0000	[thread overview]
Message-ID: <aq6utXAQA-rRoKSm@fruit.crustytoothpaste.net> (raw)
In-Reply-To: <CAKNeS+mFS_VCs_tQeFb8jBx70FwQLW0LtuqhSk4xSdbWdqDR=g@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2833 bytes --]

On 2026-09-19 at 12:19:40, Francisco Boni wrote:
> Hi,

Ney,

> There is also an unintuitive distinction between:
> 
> ```
> unset LESS
> ```
> 
> and:
> 
> ```
> LESS=""
> ```
> 
> The former causes Git to inject `FRX`, while the latter causes Git to
> leave the pager environment alone.

Yes, that's because Git sets the environment iff it is unset.  In the
latter case, it is not unset: it is set to a zero-length value.

> I realize simply removing the default could have substantial
> compatibility consequences given how longstanding this behavior is.
> But perhaps it would be worth considering whether the automatic `LESS`
> default should:
> 
> * apply only to Git's own default pager path
> * be suppressible explicitly through configuration; or
> * otherwise avoid affecting arbitrary custom `core.pager` commands.

We can't know in the general case whether the pager is less or not.  On
FreeBSD, `more` is less, for instance, and the pager command allows
arbitrary shell commands, so determining statically which branch is
taken is not always possible.  Notably, Debian has `sensible-pager`,
which is the default on that OS, and may (or may not) be less.

Users would be displeased if Git's pager functionality worked
differently with less depending on how less was invoked or named, or if
it weren't enabled in a case like the following:

    core.pager='f() { if [ "$(uname -s)" = FreeBSD ]; then more "$@"; else less "$@"; fi; };f'

A user might in fact do exactly that to make things work correctly on
multiple platforms with a single gitconfig file.  (This is why passing
certain environment variables or options to the shell is obligatory and
you cannot simply do shell parsing of the command.)

I agree that this can cause unusual behaviour in the case you've
described, but that's more of the case because it's actually unusual to
have commands that take arguments through the environment in this way.
That's no longer really considered a good design; normally we use a
config file instead these days.

I'll note that it is configurable both through the environment and
through configuration, using one of the following:

    GIT_PAGER='LESS="" delta'

or:

    git config core.pager 'LESS="" delta'

or, if you prefer to be still more conservative:

    GIT_PAGER='env -i PATH="$PATH" delta'

which unsets all environment variables but the path for your pager.

> So this is not primarily a request for a workaround; rather, I wanted
> to raise the broader behavior because the interaction with pager
> wrappers is quite surprising and difficult to diagnose.

I think at this point, we're unlikely to change the behaviour and it
would be a notable and unwelcome change to do so.
-- 
brian m. carlson (they/them)
Toronto, Ontario, CA

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 325 bytes --]

  reply	other threads:[~2026-09-19 15:48 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-19 12:19 pager: consider revisiting automatic LESS=FRX with custom core.pager Francisco Boni
2026-09-19 15:48 ` brian m. carlson [this message]
2026-09-19 16:37   ` Todd Zullinger
2026-10-02 23:41     ` [PATCH] doc: add more examples of overriding LESS in core.pager Todd Zullinger
2026-10-05 23:59       ` brian m. carlson
2026-10-06 16:01         ` Junio C Hamano
2026-09-19 16:52   ` pager: consider revisiting automatic LESS=FRX with custom core.pager Francisco Boni

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=aq6utXAQA-rRoKSm@fruit.crustytoothpaste.net \
    --to=sandals@crustytoothpaste.net \
    --cc=boboniboni@gmail.com \
    --cc=git@vger.kernel.org \
    /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