All of lore.kernel.org
 help / color / mirror / Atom feed
* pager: consider revisiting automatic LESS=FRX with custom core.pager
@ 2026-09-19 12:19 Francisco Boni
  2026-09-19 15:48 ` brian m. carlson
  0 siblings, 1 reply; 7+ messages in thread
From: Francisco Boni @ 2026-09-19 12:19 UTC (permalink / raw)
  To: git

Hi,

I ran into a surprising interaction between Git's pager environment
handling and a custom pager, and I think the longstanding automatic
`LESS=FRX` behavior may be worth revisiting.

My setup is roughly:

```
[core]
    pager = delta
```

with delta eventually invoking `less`.

In my shell I had:

```
export PAGER="less"
```

but deliberately did not set `LESS`.

I also configured delta's pager explicitly as:

```
less --RAW-CONTROL-CHARS --quit-if-one-screen --quit-on-intr --ignore-case
```

What surprised me was that:

```
git diff <commit1> <commit2>
```

caused the downstream `less` process to behave as though `-X` /
`--no-init` had been specified: it did not use the alternate screen,
and in my terminal Page Up / Page Down also stopped behaving normally.

The `less` argv itself looked as expected and did not contain `-X`.

Eventually I tracked this down to Git setting:

```
LESS=FRX
```

when `LESS` is absent from the environment.

The particularly revealing test was:

```
LESS="" git diff <commit1> <commit2>
```

With that single change, the same delta -> less chain used the
alternate screen normally and Page Up / Page Down worked again.

I understand that Git's default `LESS=FRX` behavior is old,
documented, and presumably exists to provide useful defaults when Git
directly invokes `less`.

What seems questionable to me is that it is also applied when
`core.pager` is an arbitrary custom command.

In this case the effective chain is:

```
git -> delta -> less
```

Git is not invoking `less` itself, but the `LESS=FRX` value injected
by Git is inherited by delta and then by the `less` process launched
by delta.
As a result, Git ends up silently configuring an implementation detail
of a pager wrapper. A user who explicitly configures:

```
core.pager = delta
```

would not necessarily expect Git to alter environment variables
specific to another pager that delta may or may not use internally.

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.

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.

For my own setup, explicitly setting:

```
export LESS="--RAW-CONTROL-CHARS --quit-if-one-screen --quit-on-intr
--ignore-case"
```

solves the issue cleanly, because Git then leaves `LESS` untouched.

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.

Thanks,
Francisco Boni

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-10-06 16:01 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.