Skip to content

Regressions with the terminal alternate screen in msys2-runtime 3.3.6-5 #185

Description

@Geoffrey-A

There are 2 regressions I noticed after a pacboy update, which are still observable in the latest msys2-runtime 3.4.10-1:

  1. git help X does not show the man page for X anymore. I have to resort to typing man git-X.
  2. LESS=R git show does not start the less pager in an alternate screen anymore. Because less correctly clears the text on exit, it results in blank vertical space in the terminal, corresponding to the number of lines of the screen that less used for printing content. I can still get the original desired behaviour by typing git show --color | less -R.

I have installed Git for Windows inside MSYS2, as per https://github.com/git-for-windows/git/wiki/Install-inside-MSYS2-proper.

I initially thought these regressions were caused by less, mintty, or git, but finally found out that reverting the single msys2-runtime package to 3.3.6-4 fixes both issues. Beyond the fact that they were introduced at the same time, I am now unsure of how related they are.

Indeed, from the git source code I reduced the problem 1 to the following:

#include <unistd.h>
int main(int, char**) { return execlp("man", "man", "man", (char*)NULL); }

which seems not to do anything from version 3.3.6-5 of the runtime, despite exiting with return code 0. But, replacing all occurrences of man with printf in the above produces no output either, wheareas it does print printf in version 3.3.6-4. So it seems unrelated to alternate screens after all. Please let me know if I should create 2 distinct issues.

I thought this problem could have been introduced in the Cygwin upstream. But after installing it, recompiling and running the snippet of code produced an execution of man man as expected with the cygwin package versions from 3.4.10 down to 3.4.7. I had suspected some commits in Dec 2021 or Jan 2022 which affect the cygwin pty or console. Maybe it is that some msys patches did not play well with such changes.

As for problem 2, I did not manage to get a reduction. I would tend to think that the function mingw_spawnvpe, used to spawn the less pager process and implemented in Git’s source compat/mingw.c, is a likely culprit. That would relate the two issues to process functions. But given that mingw_spawnvpe looks to be implemented in terms of the Windows API, I do not see how a msys runtime change could break it, so that seems to contradict my hypothesis.

What I found amusing about it is that running the equivalent command in PowerShell works as expected:

$env:LESS='R'; git show; $env:LESS=$null

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions