git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: "less -F" is broken

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Aug 16, 2018, 08:22 UTC
Message-ID
<87in4araa4.fsf@evledraar.gmail.com>
In-Reply-To
<CA+55aFxjUsvhHwQGthGiLr537BGHkd-LECXVv8KzBTMMCo1bKQ@mail.gmail.com>
On Wed, Aug 15 2018, Linus Torvalds wrote:
Show 12 quoted lines
> On Wed, Aug 15, 2018 at 2:29 PM Ævar Arnfjörð Bjarmason
> <avarab@gmail.com> wrote:
>>
>> 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

Show 13 quoted lines
> 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.
Show 25 quoted lines
>             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
>  	{
Previous: Linus TorvaldsNext: Mark Nudelman
Message 6 of 9 in “"less -F" is broken”
  1. Linus TorvaldsAug 15, 2018
  2. Stefan BellerAug 15, 2018
  3. Ævar Arnfjörð BjarmasonAug 15, 2018
  4. Linus TorvaldsAug 15, 2018
  5. Linus TorvaldsAug 15, 2018
  6. Ævar Arnfjörð BjarmasonAug 16, 2018
  7. Mark NudelmanAug 16, 2018
  8. Linus TorvaldsAug 16, 2018
  9. Mark NudelmanAug 20, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.