Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Garbled" character output in PowerShell when launching "git gui" #4921

Closed
patrikhuber opened this issue Mar 14, 2020 · 3 comments
Closed

"Garbled" character output in PowerShell when launching "git gui" #4921

patrikhuber opened this issue Mar 14, 2020 · 3 comments
Labels
Resolution-Duplicate There's another issue on the tracker that's pretty much the same thing.

Comments

@patrikhuber
Copy link

Environment

  • OS: Microsoft Windows NT 10.0.18362.0
  • PowerShell version: 6.2.4
  • posh-git version/path: 1.0.0 beta3 ~\Documents\PowerShell\Modules\posh-git\1.0.0
  • git version 2.25.0.windows.1

Steps to reproduce

In a PowerShell, with posh-git and git-for-windows (which includes git gui) installed:

When typing git gui, the git gui window opens, but on the powershell prompt, the encoding of the characters is outputted and the cursor stays on that line. Only after pressing "Enter", the prompt becomes "normal" again.

~\MyProj [mybranch +2 ~2 -0 !]> git gui    <-- nicely colourised
~\MyProj �[93m[�[0m�[96mmybranch�[0m�[31m�[49m +2�[0m�[31m�[49m ~2�[0m�[31m�[49m -0�[0m�[31m !�[0m�[93m]�[0m>    <-- no colours, "weird" output. Have to press "enter" to get prompt to normal again.
~\MyProj [mybranch +2 ~2 -0 !]>    <-- nicely colourised

image

Expected behavior

Quite obvious I think, the PowerShell prompt should output the "normal" prompt with the coloured characters and stuff (from posh-git).

Actual behavior

Stuff like �[93m[�[0m is output (see above/screenshot).

Related issues

I've opened dahlbyk/posh-git#738 first but the author suggested it's likely a git-gui issue. I've then opened prati0100/git-gui#34 but the author said it might likely be a Windows Terminal issue and related to #4809. After posting in #4809, @DHowett-MSFT advised to open a new issue here, as my issue is with PowerShell, and not with git-bash.

@ghost ghost added Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels Mar 14, 2020
@DHowett-MSFT
Copy link
Contributor

DHowett-MSFT commented Mar 14, 2020

Alright, I just got this thing under event tracing. Here's what I found (annotated)

image

(time goes from left to right)

What's happening is this:

  1. I type in git gui, press enter
  2. Powershell disables VT rendering (for compatibility reasons), setting mode=3
  3. git.exe launches, and kicks off a sequence of processes (one of which is sh.exe)
  4. git.exe exits, returning control to Powershell
  5. Powershell re-enables VT rendering, setting mode=7
  6. Powershell prints its prompt, or when it's being slow it doesn't print its prompt.
  7. sh.exe, which was spawned under line 3, disables VT rendering (mode=3)
  8. Powershell finishes printing the prompt and begins taking user input
  9. When the user types, powershell tries to use VT (disabled on line 7) to color it
  10. This happens: image

Unfortunately, there isn't anything powershell (or the windows console!) can do to help this situation: the output mode is console-wide global state, and sh.exe is setting that global state to ignore powershell's text rendering commands—after powershell was put back in control.

@DHowett-MSFT
Copy link
Contributor

In light of all this, I've filed /dup #4954 to track figuring out whether we can make the output handle mode process-local state instead of global state.

@ghost
Copy link

ghost commented Mar 17, 2020

Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!

@ghost ghost closed this as completed Mar 17, 2020
@ghost ghost added Resolution-Duplicate There's another issue on the tracker that's pretty much the same thing. and removed Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels Mar 17, 2020
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution-Duplicate There's another issue on the tracker that's pretty much the same thing.
Projects
None yet
Development

No branches or pull requests

2 participants