Git diffs use pagination inconsistently
Affected Version
yay v9.4.6 - libalpm v12.0.1
Issue
When I'm reviewing AUR package changes while running yay, the diffs are paginated inconsistently. If there's a package with a diff longer than the screen height, it'll show only that diff in what seems to be less. When I press Q to continue reviewing, and what remains is a bunch of packages with small diffs, they end up in the scrollback, and I have to scroll back up to see them all, trying to work out where I was up to.
It seems like the current functionality is something akin to sequentially running git diff ... in each package's repo, which has the effect of each one separately being possibly paginated.
I think the desired functionality would be to collect all the diffs, and then paginate that. This could be done by adding the --no-pager flag to the Git command (git --no-pager diff), and piping that into less (but then needing to use the --color Git flag to keep colour enabled, and less -R to interpret ANSI colour safely).
Also, including titles to separate the packages diffs more clearly would be great.
Right, sorry, I didn't realise this was addressed in the readme:
Sometimes diffs are printed to the terminal, and other times they are paged via less. How do I fix this?
Yay uses
git diffto display diffs, which by default tells less not to page if the output can fit into one terminal length. This behavior can be overridden by exporting your own flags (export LESS=SRX).
Using this workaround, I think I prefer LESS=SR, which forces each package's diff to be separately paginated on a clean screen, no matter the length.
A quick improvement could be for Yay to default the LESS environment variable to SR if it's unset. Although this could make it tricky to quit early if you disagree with the content of a diff.
Still, I think it would be preferable to show all the diffs at once, separated by title.
For now at least, I will be adding this alias to my dotfiles:
alias yay='LESS=SR yay'
I think the option you're looking for is:
-F or --quit-if-one-screen
Causes less to automatically exit if the entire file can be displayed on the first screen.
If less were invoked with -+F, this would reset this to the default value. (I tested, it works on a simple file view)
So, maybe you could invoke git as LESS="$LESS -+F" git diff ...
Because invoking as LESS="$LESS -+F" yay ... sadly doesn't work.
Perhaps each call to git diff needs to be piped to less -+F rather than being printed directly to the screen?
I think this issue could be closed? @ZimbiX @Jguer
@Jguer @ZimbiX @grandchild Please consider reopening this issue...
The suggestions I've made don't resolve the issue.
Example: if there are 5 diffs that take up about 20 lines each, and these are printed one after another, all 100 lines will be dumped at once, and only the last screenful will actually be visible.
This works, but prints every file separately. It pauses after each file.
PAGER='less $LESS -+F' /usr/bin/yay -aSu
My preferred behaviour is printing the diff for the whole package, and pausing only once at the end.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Please reopen
My preferred behaviour is printing the
difffor the whole package, and pausing only once at the end.
I agree; this behavior would make a lot more sense. It's weird that it's not already the default because it's the most obvious way to diff an AUR repository. If you have an AUR repo cloned locally, and you do git diff HEAD origin, it just works, exactly like you'd expect. I think that's what many users would like to see yay do as well.
@Jguer I believe this was closed by mistake. It's "stale", but only because there isn't a lot users can add to the topic.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.