Re: "less -F" is broken
From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2018-08-16 08:22:20
On Wed, Aug 15 2018, Linus Torvalds wrote:
On Wed, Aug 15, 2018 at 2:29 PM Ævar Arnfjörð Bjarmason [off-list ref] wrote:quoted
Downloading & trying versions of it locally reveals that it's as of version 520, not 530. The last version before 520 is 487. Presumably it's covered by this item in the changelog: Don't output terminal init sequence if using -F and file fits on one screen[1]Side note: that's sad, because we already use X in the default exactly for that reason.
And as another note for those following along (and myself until a short while ago, I didn't remember how this worked). We set those default options at compile-time here: https://github.com/git/git/blob/63749b2dea5d1501ff85bab7b8a7f64911d21dea/Makefile#L1761-L1763 I.e. set LESS=FRX and then when we setup the pager we use that unless we can find LESS (and LV) set in the env already: https://github.com/git/git/blob/63749b2dea5d1501ff85bab7b8a7f64911d21dea/pager.c#L71-L96
So apparently "less" was broken for us to fix something that we already had long solved. The code basically tried to do "automatic X when F is set". And all that line_count stuff (which is what breaks) is pointless when -X is already given. That does give a possible fix: just stop doing the line_count thing if no_init is set. So "-F" would continue to be broken, but "-FX" would work. Something like the attached patch, perhaps?
This works for me under -FX.
quoted hunk ↗ jump to hunk
Linus main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)diff --git a/main.c b/main.c index 179bd78..961a9db 100644 --- a/main.c +++ b/main.c@@ -59,6 +59,7 @@ extern int missing_cap; extern int know_dumb; extern int pr_type; extern int quit_if_one_screen; +extern int no_init; /*@@ -274,7 +275,7 @@ main(argc, argv) { if (edit_stdin()) /* Edit standard input */ quit(QUIT_ERROR); - if (quit_if_one_screen) + if (quit_if_one_screen && !no_init) line_count = get_line_count(); } else {