Skip to content

Weird interaction with git add -p and Notepad++ (git hangs) #4776

Closed
git-for-windows/msys2-runtime
#87

Description

@klylesatepic
  • I was not able to find an open or closed issue matching what I'm seeing

Previously reported at microsoft/terminal#16553 and msys2/msys2.github.io#307.

Setup

  • Which version of Git for Windows are you using? Is it 32-bit or 64-bit?
    Seen with both versions 2.42.0.windows.2 and 2.43.0.windows.1 (64-bit)
$ git --version --build-options
git version 2.43.0.windows.1
cpu: x86_64
built from commit: 4b968f3ea3b32a7bc50846bab49f3f381841d297
sizeof-long: 4
sizeof-size_t: 8
shell-path: /bin/sh
feature: fsmonitor--daemon
  • Which version of Windows are you running? Vista, 7, 8, 10? Is it 32-bit or 64-bit?
    Seen on both version 10.0.19044.3930 and 10.0.22621.2861
$ cmd.exe /c ver

Microsoft Windows [Version 10.0.19044.3930]
  • What options did you set as part of the installation? Or did you choose the
    defaults?
# One of the following:
> type "C:\Program Files\Git\etc\install-options.txt"
> type "C:\Program Files (x86)\Git\etc\install-options.txt"
> type "%USERPROFILE%\AppData\Local\Programs\Git\etc\install-options.txt"
> type "$env:USERPROFILE\AppData\Local\Programs\Git\etc\install-options.txt"
$ cat /etc/install-options.txt

Editor Option: VIM
Custom Editor Path:
Default Branch Option: main
Path Option: Cmd
SSH Option: OpenSSH
Tortoise Option: false
CURL Option: WinSSL
CRLF Option: CRLFAlways
Bash Terminal Option: MinTTY
Git Pull Behavior Option: Rebase
Use Credential Manager: Enabled
Performance Tweaks FSCache: Enabled
Enable Symlinks: Disabled
Enable Pseudo Console Support: Disabled
Enable FSMonitor: Enabled
  • Any other interesting things about your environment that might be related
    to the issue you're seeing?

I don't think so, but I'm happy to answer further questions.

Details

  • Which terminal/shell are you running Git from? e.g Bash/CMD/PowerShell/other

Git Bash in Windows Terminal

  1. Open Git Bash in Windows Terminal
  2. Navigate to a git repository
  3. Make changes in at least two separate places in a file
  4. Run GIT_EDITOR='"C:\Program Files\Notepad++\notepad++.exe" -multiInst -notabbar -nosession -noPlugin' git add -p to interactively stage parts of the file
    • Obviously you will need Notepad++ installed, and you may need to adjust the path to it
  5. Type e to edit the first hunk (Notepad++ will open)
  6. Make whatever change you like within one of the new lines (starting with a plus)
  7. Save and close Notepad++
  8. See that git moves on and prompts for the next hunk
  9. Try to type n to skip the next hunk (or anything else)
  10. See that git is stuck (Ctrl+C won't interrupt it)

The same issue happens with git add -i instead of git add -p, but requires more steps between steps 4/5.

The issue does not happen if any of the following are true:

  • You use vanilla Git Bash instead of Git Bash in Windows Terminal

  • You use cygwin instead of Git Bash in Windows Terminal (with a slightly different GIT_EDITOR value to account for differences in path handling)

  • You only edit the last hunk

  • You use a terminal editor instead of Notepad++ (I tried vim and nano)

  • You use /c/Windows/System32/notepad.exe instead of Notepad++

    • The bug still happens if you just use 'notepad', which is a shell script in Git Bash located at /usr/bin/notepad
  • What did you expect to occur after running these commands?

Input would be accepted for dealing with the next hunk, and git would not hang.

  • What actually happened instead?

Input is not accepted (or at least not echoed), and git hangs.

  • If the problem was occurring with a specific repository, can you provide the
    URL to that repository to help us with testing?

Not repository specific.

Activity

  1. richbern commented on Jun 14, 2024

    @richbern

    Experiencing this issue and want to track any updates. I prefer notepad++ as my general quick editor and would prefer not to have to change that or remember to change the editor before doing an add -i.

  2. ehm214 commented on Aug 1, 2024

    @ehm214

    In case it helps, I'm pretty sure I'm experiencing the same issue with VSCode as my editor.

    The steps to reproduce are the same, except for step 4, you want GIT_EDITOR="code --wait" assuming you have VSCode in your PATH.

    I switched to using vanilla Git Bash for the file where I was experiencing the issue as a workaround.

  3. dscho commented on Sep 28, 2024

    @dscho
    Member

    Could you please test with Git for Windows v2.47.0-rc0? It comes with a new MSYS2 runtime version that I hope fixes this (in my tests, it did).

  4. klylesatepic commented on Sep 30, 2024

    @klylesatepic
    Author

    Unfortunately, I see no change in behavior with that version installed.

    $ git --version
    git version 2.47.0.rc0.windows.1

  5. dscho commented on Sep 30, 2024

    @dscho
    Member

    @klylesatepic oh, I fear I forgot to take out the no-longer-experimental option 'Enable experimental support for pseudo consoles.'. It should be removed and turned on by default. Could I ask you to reinstall and ensure that this option is checked?

  6. klylesatepic commented on Sep 30, 2024

    @klylesatepic
    Author

    I reinstalled and made sure that option was checked during the installation. I still see no change in behavior.

  7. richbern commented on Sep 30, 2024

    @richbern
  8. dscho commented on Sep 30, 2024

    @dscho
    Member

    Thank you both for checking! I will try to reproduce this again, maybe it has something to do with my using the Git for Windows SDK that it started working here.

  9. generalmimon commented on Sep 30, 2024

    @generalmimon

    @dscho Perhaps if you want to make sure you're testing in a clean isolated environment and can use Windows Sandbox, these personal notes of mine showing how to install Windows Terminal within the sandbox might be useful to you. There might be better tools for this, but one thing I like about Windows Sandbox is that it just works out of the box (without having to configure anything) and I can be reasonably sure that whatever I do inside is isolated from the host environment.

  10. dscho commented on Oct 1, 2024

    @dscho
    Member

    if you want to make sure you're testing in a clean isolated environment and can use Windows Sandbox

    The problem with that is that I need to reproduce this in an environment where I can easily develop a fix, meaning a full Git for Windows SDK from which I can open PRs. Due to time constraints, that means that I cannot afford to set up a brand new environment for every bug report I receive ☹

  11. dscho commented on Oct 1, 2024

    @dscho
    Member

    Oh never mind, I missed something and sure enough, I can still reproduce, even with Git for Windows v2.47.0-rc0 ☹

  12. dscho commented on Mar 3, 2025

    @dscho
    Member

    This might be fixed via git-for-windows/msys2-runtime#87. Please download the install artifact from https://github.com/git-for-windows/msys2-runtime/actions/runs/13628995018?pr=87#artifacts, extract its usr\bin\msys-2.0.dll and (temporarily) replace your regular Git installation's version, then try again? In my tests, it fixes the problem.

  13. klylesatepic commented on Mar 3, 2025

    @klylesatepic
    Author

    This might be fixed via git-for-windows/msys2-runtime#87. Please download the install artifact from https://github.com/git-for-windows/msys2-runtime/actions/runs/13628995018?pr=87#artifacts, extract its usr\bin\msys-2.0.dll and (temporarily) replace your regular Git installation's version, then try again? In my tests, it fixes the problem.

    That does appear to fix it! Thank you for continuing to follow up on this.

  14. dscho commented on Mar 3, 2025

    @dscho
    Member

    This might be fixed via git-for-windows/msys2-runtime#87. Please download the install artifact from https://github.com/git-for-windows/msys2-runtime/actions/runs/13628995018?pr=87#artifacts, extract its usr\bin\msys-2.0.dll and (temporarily) replace your regular Git installation's version, then try again? In my tests, it fixes the problem.

    That does appear to fix it! Thank you for continuing to follow up on this.

    Yay!

  15. added this to the Next release milestone on Mar 3, 2025
  16. dscho commented on Mar 3, 2025

    @dscho
    Member

    /add relnote bug A bug has been fixed that, when calling git add -p from VS Code's internal terminal, after using the edit command, caused the internal terminal got stuck and no further command was accepted.

    The workflow run was started

  17. added a commit that references this issue on Mar 3, 2025
  18. added a commit that references this issue on May 7, 2025
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions