Re: [PATCH 5/5] add-patch: render hunks through the pager
- From
- Dragan Simic <dsimic@manjaro.org>
- Date
- May 20, 2024, 19:45 UTC
- Message-ID
- <ec5d73e22a6e4587f3d87314a9c0e422@manjaro.org>
- In-Reply-To
- <xmqqh6esffh1.fsf@gitster.g>
Hello Junio and Ruben,
On 2024-05-20 21:30, Junio C Hamano wrote:
Show 25 quoted lines
> Rubén Justo <rjusto@gmail.com> writes: > >> Invoke the pager when displaying hunks during "add -p" sessions, to >> make >> it easier for the user to review hunks longer than one screen height. > > If the hunk fits on one screen, it is annoying to see a pager > invoked and then torn down immediately, even with "less -F" > (--quit-if-one-screen). As we know how much output we are throwing > at the user, we'd want to make this conditional to the size of the > hunk being shown and the terminal height. > > Or perhaps show them without such a trick, and add a new variant to > 'p' that allows the user to request the output be sent to a pager > (perhaps 'P')? It would certainly be an alternative with much > smaller damage. The existing end-user experience would not degrade, > but when the user wants to see a huge hunk, they can send it to the > pager. > > Another, ulteriour, motive here behind this suggestion is to > encourage users to work with smaller hunks. Being able to scroll > around and view lines on demand (i.e. use of pager) is one thing. > Being able to view all relevant lines at once (i.e. not wasting > vertical screen real estate and making things fit on one screen) is > very different and much nicer.
There's another thing to consider, which makes the introduction of "P" as the new option even more desirable. Let me explain.
With the upcoming changes to the way less(1) as the pager works, which was already discussed at length and even required new features to be implemented in less(1), [1] displaying anything through less(1) will not leave an accessible scrollback in the terminal emulator. Only one screen worth of text will be displayed, even after quitting less(1). That's what we have to do, to fix age-old issues with the pager-generated scrollback that easily gets corrupted and actually becomes misleading.
Thus, if someone wants to have a complete longer-than-one-screen hunk displayed and use the terminal emulator scrollback to inspect the hunk in its entirety, passing such (or all) hunks through the pager would make such inspection impossible. I'd assume that at least some Git users already do that (I do, for example), and we surely don't want to make that no longer possible. That's why introducing "P" as the new option would be the desired approach.
[1] https://lore.kernel.org/git/8289ef15266172cbfa10bb146afe9797@manjaro.org/