Skip to content

Git output oddly indented and sometimes causing crash with TERM=msys #10152

Closed

Description

Windows Terminal version (or Windows build number)

1.7.1033.0

Other Software

Using Git for Windows version 2.31.1.windows.1 with the bundled vim v8.2.1895 with PowerShell 5.1.19041.906.

Steps to reproduce

In a new folder, enter the following commands after another:

PS C:\TerminalIssueRepro> $env:TERM = 'msys'
PS C:\TerminalIssueRepro> git init
PS C:\TerminalIssueRepro> 'bin/' > .gitignore
PS C:\TerminalIssueRepro> git add .\.gitignore
PS C:\TerminalIssueRepro> git commit

vim opens to prompt for a commit message, so enter something there, save and exit.

Expected Behavior

The console window should look like this:

PS C:\TerminalIssueRepro> git init
Initialized empty Git repository in C:/TerminalIssueRepro/.git/
PS C:\TerminalIssueRepro> 'bin/' > .gitignore
PS C:\TerminalIssueRepro> git add .\.gitignore
PS C:\TerminalIssueRepro> git commit
[main (root-commit) abe2cba] Initialize
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 .gitignore
PS C:\TerminalIssueRepro> 

Actual Behavior

Instead, due to the TERM=msys, the output looks like this:

PS C:\TerminalIssueRepro> git init
Initialized empty Git repository in C:/TerminalIssueRepro/.git/
PS C:\TerminalIssueRepro> 'bin/' > .gitignore
PS C:\TerminalIssueRepro> git add .\.gitignore
PS C:\TerminalIssueRepro> git commit
[main (root-commit) abe2cba] Initialize
                                        1 file changed, 0 insertions(+), 0 deletions(-)
                                                                                        create mode 100644 .gitignore

This can be reproduced by re-triggering vim for editing, e.g. using git commit --amend. Sometimes, the terminal process completely crashes after closing vim, e.g. with this output:

PS C:\TerminalIssueRepro> git commit --amend
[main 27a142f] Initialize
                          Date: Sat May 22 14:20:41 2021 +0200
                                                               1 file changed, 0 insertions(+), 0 deletions(-)
                                                                                                               create mode 100644 .gitignore
[Verarbeitung des Prozesses mit Code 5 beendet]

(Eror message says “Processing of process ended with code 5”)

If I switch to the TERM mode cygwin (the default I believe?), then the output will look ok in that there is no odd indentation and the process won’t crash. However doing so means that after exiting vim, the screen will be completely blank above the generated output, i.e. the vim process blanks the previous console output.

In ConEmu, using TERM=msys works without any problems, so does it in the native PowerShell host or cmd.exe.

Activity

  1. ghost added
    Needs-Triage
    on May 22, 2021
  2. ghost added
    Needs-Tag-Fix
    on May 22, 2021
  3. added
    Area-Output
    on May 24, 2021
  4. DHowett commented on May 27, 2021

    @DHowett
    Member

    This is fascinating.

    /feedback

  5. ghost added
    Needs-Author-Feedback
    on May 27, 2021
  6. poke commented on May 28, 2021

    @poke
    Author

    I unfortunately cannot use the Feedback hub on this machine since my domain policies prevent me from changing the data privacy settings that are required to use it… I can try to replicate this during the weekend on a different computer.

    For what it’s worth, I couldn’t replicate the crash just now (of course not… 🙄) but here you have a screenshot of the funny output:

    Screenshot of the oddly indented output

  7. ghost added
    Needs-Attention
    on May 28, 2021
  8. ghost removed
    Needs-Author-Feedback
    on May 28, 2021
  9. carenas commented on Sep 6, 2021

    @carenas

    interestingly; observing the odd formatting issue also but using the default TERM=xterm-color (or xterm) and a git bash tab, I also don't see the problem if using git bash directly (hence mintty) or the regular console (cmd or powershell)

    TERM=cygwin workarounds the problem, and the issue can be seen in both the release and preview versions of Windows Terminal

    UPDATE: built a custom git version to debug the formatting, and it would seem to be a residual misconfiguration of the terminal after vim closes, if using a different EDITOR for commit message the problem is not reproducible either regardless of TERM

  10. zadjii-msft commented on Sep 7, 2021

    @zadjii-msft
    Member

    Wait so, after your update I'm not entirely clear what the state of this is. Did this go away with a updated git version? If not, then I'd be interested in the diff between the infocmp for xterm-color, cygwin, and ansi.

    WAIT is this vim.exe, or a vim that ships with msys/cygwin?

  11. added
    Needs-Author-Feedback
    and removed
    Needs-Attention
    on Sep 7, 2021
  12. carenas commented on Sep 7, 2021

    @carenas

    Wait so, after your update I'm not entirely clear what the state of this is. Did this go away with a updated git version?

    no, but it could be handled there even if we don't have yet the facilities to do so.

    If not, then I'd be interested in the diff between the infocmp for xterm-color, cygwin, and ansi.

    git for windows doesn't have ansi on its terminfo, but xterm-256color and cygwin diff in:

    https://pastebin.com/y4pwLZ1D

    WAIT is this vim.exe, or a vim that ships with msys/cygwin?

    msys vim, which comes with git for windows and is invoked by default through a shell script in the emulated POSIX tree as /usr/bin/vi

    you can reproduce it locally by installing git for windows[1] and running the git bash integration with windows terminal AS-IS.

    [1] https://gitforwindows.org/

  13. reece-bennett commented on Sep 11, 2021

    @reece-bennett

    I'm not seeing any crashes but am experiencing the misaligned output.

    I'm on git version 2.32.0.windows.2 and using vim as my editor (the default one that comes bundled with Git for Windows).

    Everything looks fine in mintty that Git for Windows installs:

    git-bash

    But in Windows Terminal I get the odd output (also happening for me in VSCode terminal):

    windows-terminal

  14. ghost added
    No-Recent-Activity
    on Sep 15, 2021
  15. zadjii-msft commented on Sep 15, 2021

    @zadjii-msft
    Member

    You know, we've got the same exact thing going on over in #9359, so I[m gonna close this as a dupe an put all the discussion in one place. Thanks! /dup #9359

  16. ghost removed
    No-Recent-Activity
    on Sep 15, 2021
  17. ghost closed this as completedon Sep 15, 2021
  18. ghost removed
    Needs-Triage
    on Sep 15, 2021
  19. ghost added
    Resolution-Duplicate
    on Sep 15, 2021
  20. ghost removed
    Needs-Tag-Fix
    on Sep 15, 2021
  21. ghost removed
    Needs-Author-Feedback
    on Sep 15, 2021
  22. carenas commented on Oct 2, 2021

    @carenas

    Did this go away with a updated git version?

    Yes and no; I coded a branch with the facility that was missing in git to be able to handle this terminal corruption, and I am able to solve the endemic problem that was reported here and in other related tickets.

    WAIT is this vim.exe, or a vim that ships with msys/cygwin?

    vim is using an msys pty, while git is using a conio (hence conPTY when supported), but IMHO that configuration should work and it almost does (vi is able to change the terminal settings and control its screen and almost return it back clean); the only missing flag that is evident would seem to be "onlcr" and my code fixes that part by clearing that missing DISABLE_NEWLINE_AUTO_RETURN after vim exit.

    BUT if I kill vim forcefully, there are a lot more flags that are not set correctly and EVEN if I am writing back the same conio flags from before vim was spawned, the terminal is still missing onlcr and shows the indented output, therefore still requiring a reset.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-OutputResolution-Duplicate

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions