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