diff options
author | Chih-Hsuan Yen <x5f4qvj3w3ge2tiq@chyen.cc> | 2023-05-24 22:32:23 +0800 |
---|---|---|
committer | Chih-Hsuan Yen <x5f4qvj3w3ge2tiq@chyen.cc> | 2023-05-26 14:39:09 +0000 |
commit | 07a4529278f4112e3a98686f01db6b05fea5f280 (patch) | |
tree | b9e65112d63494efcefddaeb528ffc1346068d67 /pager.py | |
parent | 17833322d9e0c650310e55f806d5e3545c265c2a (diff) | |
download | git-repo-07a4529278f4112e3a98686f01db6b05fea5f280.tar.gz |
pager: set $LESS only when missing
This matches the git behavior. From [1],
> When the `LESS` environment variable is unset, Git sets it to `FRX`
> (if `LESS` environment variable is set, Git does not change it at
> all).
The default $LESS is changed from FRSX to FRX since git 2.1.0 [2]. This
change also updates the default $LESS for repo.
[1] https://git-scm.com/docs/git-config#Documentation/git-config.txt-corepager
[2] https://github.com/git/git/commit/b3275838d969b7ecb91aae584226fccbeb046aca
Bug: https://crbug.com/gerrit/16973
Change-Id: I64ccaa7b034fdb6a92c10025e47f5d07e85e6451
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/374894
Reviewed-by: Chih-Hsuan Yen <x5f4qvj3w3ge2tiq@chyen.cc>
Reviewed-by: Mike Frysinger <vapier@google.com>
Tested-by: Chih-Hsuan Yen <x5f4qvj3w3ge2tiq@chyen.cc>
Diffstat (limited to 'pager.py')
-rw-r--r-- | pager.py | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -118,7 +118,10 @@ def _BecomePager(pager): | |||
118 | # available versions of 'less', a better 'more'. | 118 | # available versions of 'less', a better 'more'. |
119 | _a, _b, _c = select.select([0], [], [0]) | 119 | _a, _b, _c = select.select([0], [], [0]) |
120 | 120 | ||
121 | os.environ["LESS"] = "FRSX" | 121 | # This matches the behavior of git, which sets $LESS to `FRX` if it is not |
122 | # set. See: | ||
123 | # https://git-scm.com/docs/git-config#Documentation/git-config.txt-corepager | ||
124 | os.environ.setdefault("LESS", "FRX") | ||
122 | 125 | ||
123 | try: | 126 | try: |
124 | os.execvp(pager, [pager]) | 127 | os.execvp(pager, [pager]) |