Skip to content

git bash for windows in terminal does not break lines correctly #9359

Open

Description

@RedX2501

Environment

Platform ServicePack Version      VersionString
-------- ----------- -------      -------------
 Win32NT             10.0.18363.0 Microsoft Windows NT 10.0.18363.0

Windows Terminal Preview
Version: 1.7.572.0

Setting for git bash:

            {
                "name": "git bash",
                "commandline": "%PROGRAMFILES%/git/usr/bin/bash.exe -i -l",
                "icon": "%PROGRAMFILES%/Git/mingw64/share/git/git-for-windows.ico",
                "startingDirectory" : "%USERPROFILE%"
            },

Steps to reproduce

  1. Open a terminal window with git for windows bash
  2. Do a rebase operation

Expected behavior

Line breaks start at the beginning of the next line.

Actual behavior

git rod is an alias for git rebase --autostash -i origin/develop

$git rod
error: could not apply 6b04f92e... DuplicateInput now supports generating code for arrays for the VfcTypeImplementation
                                                                                                                                  Resolve all conflicts manually, mark them as resolved with
                                                                                                                                                                                            "git add/rm <conflicted_files>", then run "git rebase --continue".
                                                                                                                                                                                                                                                              You can instead skip this commit: run "git rebase --skip".
                                           To abort and get back to the state before "git rebase", run "git rebase --abort".
                                                                                                                            Recorded preimage for 'src/App/Changelog.md'
                                                                                                                                                                        Could not apply 6b04f92e... DuplicateInput now supports generating code for arrays for the VfcTypeImplementation
                      Auto-merging src/App/Tests/Silt.Plugin.SimpleTransformersGeneratorTests/GeneratorTests/DuplicateInputTransformerTests.cs
                                                                                                                                              Auto-merging src/App/Plugins/Silt.Plugin.SimpleTransformersGenerator/GeneratorStrategy/DuplicateInputTransformer.cs
                                                                                                                                                                                                                                                                 Auto-merging src/App/Changelog.md
                     CONFLICT (content): Merge conflict in src/App/Changelog.md

It seems that only the console without \r is not returning the operator to the beginnig of the line.

Not sure if there is a setting I need to configure for this to work.

Activity

  1. ghost added
    Needs-TriageIt's a new issue that the core contributor team needs to triage at the next triage meeting
    on Mar 3, 2021
  2. ghost added
    Needs-Tag-FixDoesn't match tag requirements
    on Mar 3, 2021
  3. zadjii-msft commented on Mar 3, 2021

    @zadjii-msft
    Member

    Dustin L. Howett (@DHowett) can you sanity check what's going on here? I forget how mingw works some times. We've had this one and #9312 in the course of a single week, and I don't think we changed anything about our console mode handling.

  4. added
    Area-OutputRelated to output processing (inserting text into buffer, retrieving buffer text, etc.)
    on Mar 3, 2021
  5. RedX2501 commented on Mar 4, 2021

    @RedX2501
    Author

    Forgot to mention I saw this on preview. I have not checked on the "official" version yet. I have added the version number to the post above.

  6. RedX2501 commented on Mar 4, 2021

    @RedX2501
    Author

    I also see this in the official version

    Windows Terminal
    Version: 1.6.10571.0
    
    $git rebase -i develop
    Successfully rebased and updated refs/heads/testing.
                                                        myPc /c/data/sw testing
    
  7. RedX2501 commented on Mar 5, 2021

    @RedX2501
    Author

    Today this led to a buffer overrun exception:

    image001

  8. zadjii-msft commented on Mar 5, 2021

    @zadjii-msft
    Member

    Well that's super weird. I don't think that's necessarily caused by the same thing that's causing the \r to get dropped here. We've seen that before in #7763, but that had more to do with resizing the buffer with DBCS characters in it, and presumably that's not happening in this case.

    If that happens again, can you use task manager to capture a dump file of Terminal when that dialog pops up?

  9. ffes commented on Jul 9, 2021

    @ffes

    I see this behavior with every git commit I do. Other git subcommands seem to work for me, though I haven't used rebase recently. Never ran into the buffer overrun, mentioned above.

    FYI:
    Windows Terminal Preview Version: 1.9.1523.0
    git version 2.31.1.windows.1

  10. KalleOlaviNiemitalo commented on Jul 10, 2021

    @KalleOlaviNiemitalo

    Does stty onlcr help?

  11. KalleOlaviNiemitalo commented on Jul 10, 2021

    @KalleOlaviNiemitalo

    Regarding the error message:

    The system detected an overrun of a stack-based buffer in the application. This overrun could potentially allow a malicious user to gain control of this application.

    As described in STATUS_STACK_BUFFER_OVERRUN doesn’t mean that there was a stack buffer overrun, the same exception code is nowadays used for other purposes too. I don't know whether Windows nowadays bothers to check the fast-fail code before it pops up the message box with this wording.

  12. ghost removed
    Needs-Tag-FixDoesn't match tag requirements
    on Sep 15, 2021
  13. 30 remaining items

  14. added this to the 22H2 milestone on Jan 4, 2022
  15. C0DK commented on Feb 18, 2022

    @C0DK

    I am experiencing something similar with WSL 2.0 and Ubuntu in the Windows Terminal, with git version 2.25.1 - yet that shouldn't be git for windows; but just plain old git:

    image

    It happens after having run an interactive rebase (which I assume is also when vim is opened.). I've set the editor to vim, (as per Carlo Marcelo Arenas Belón (@carenas) suggestion) rather than the full vim-path, yet it didn't do anything better or worse.

    Is this related to the problem? and do you brilliant people know of any quick fix?

  16. carenas commented on Feb 18, 2022

    @carenas

    Is this related to the problem? and do you brilliant people know of any quick fix?

    the mentioned workaround only applies to git for windows (requires code in git that is not part of the regular codebase yet).

    it definitely looks like the same problem, and as documented in #10152 another workaround that doesn't require code changes is to set TERM to something else than xterm*; ex:

    > export TERM=vt100
    

    it is important also to note that running reset after vi is invoked should also fix the terminal, as well as fixing your rbim command/alias so it doesn't attempt to run vi in a non terminal, if that is possible (expect might help there)

  17. C0DK commented on May 16, 2022

    @C0DK

    I never tested vt100, Carlo Marcelo Arenas Belón (@carenas) - i did now.

    image

    vt100 didn't do much more than removing my beautiful colors. Reset is currently my preferred trick. but might just postfix the reset command to my alias.

  18. carenas commented on May 16, 2022

    @carenas

    vt100 didn't do much more than removing my beautiful colors

    will see if I can try again to get my fix merged into git upstream (hopefully for 2.37), which then could be maybe backported to your version; but considering your version is old and probably out of maintenance it might be worth upgrading it regardless.

  19. zadjii-msft commented on Nov 8, 2022

    @zadjii-msft
    Member

    Carlo Marcelo Arenas Belón (@carenas) You know if this was ever fixed upstream? Or, if it wasn't, is there an upstream issue we could point this thread at?

  20. carenas commented on Nov 8, 2022

    @carenas

    You know if this was ever fixed upstream?

    AFAIK the "fix" implemented in git for windows[1] is only a workaround to the effects of this bug.

    [1] git-for-windows/git@db157fb

  21. othmanalikhan commented on Feb 11, 2023

    @othmanalikhan

    I'm experiencing a similar situation where Git Bash for Windows messed up line wrapping (and consequently doesn't break lines properly). To replicate:

    1. Open Git Bash session in Windows Terminal
    2. Just press up-arrow to load a command from history
    3. Move the cursor to the start of the line of the command that appears, and that becomes rather wonky (especially for long commands that should be line broken).

    See this image to illustrate:

    image

    I should add that changing the $TERM variable can sometimes fix it but sometimes makes things even more wonkier.

    EDIT: Nevermind, found my issue and it isn't caused by Windows Terminal... I had a function in my .bashrc that was overriding the $PS1 variable incorrectly. Fixed it and confirm everything is working. This issue was plaguing me for about a year now... But no longer.

  22. carlos-zamora commented on Feb 22, 2023

    @carlos-zamora
    Contributor

    Hi all! There's been a lot of changes in this space recently, and we're hoping it gets better with 1.18 which is slated to come out in a few months.

  23. removed
    Needs-TriageIt's a new issue that the core contributor team needs to triage at the next triage meeting
    on Feb 22, 2023
  24. lost-scripts commented on Jul 2, 2024

    @lost-scripts

    FWIW, in my case what triggers the issue is this line...

    export MSYS=winsymlinks:nativestrict # Allow symlink creation on Windows perpetually

    ...that I added at some point to my .bashrc file. IOW, I've just discovered that if I comment that line and relaunch the terminal I get the expected output:

    20240702-2204_correct

    Whereas as soon I uncomment it and relaunch the terminal, I start getting this again:

    20240702-2206_wrong

    Curious thing is for some reason the behavior only changes after the second interaction once activated/deactivated the culprit line (no matter if I relaunch or reload), as can be seen in the first capture. Well, I hope it somehow helps, or give some clue at least, on figuring out what could be going on cause it's certainly annoying... and what if (as happen to be the case) you need such or other similar settings to be active? 🙄 Cheers.


    git version 2.45.1.windows.1
    GNU bash, version 5.2.26(1)-release (x86_64-pc-msys)

  25. DHowett commented on Jul 2, 2024

    @DHowett
    Member

    If toggling an msys feature on and off changes the behaviour of msys, it may be worth filing a bug on msys! I'm not sure how that would impact Terminal, but it is a really great data point. Thanks!

    FWIW: it looks like that terminal is mintty, so we might not even be involved here (since msys applications use a special connection they have with mintty to skip all the Windows Console code)

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-OutputRelated to output processing (inserting text into buffer, retrieving buffer text, etc.)Issue-BugIt either shouldn't be doing this or needs an investigation.Priority-2A description (P2)Product-TerminalThe new Windows Terminal.

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions