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

After exiting commit editor whole console get cleared #5303

Open
Yankes opened this issue Dec 6, 2024 · 7 comments
Open

After exiting commit editor whole console get cleared #5303

Yankes opened this issue Dec 6, 2024 · 7 comments
Labels

Comments

@Yankes
Copy link

Yankes commented Dec 6, 2024

  • [ v] I was not able to find an open or closed issue matching what I'm seeing

Setup

  • Which version of Git for Windows are you using? Is it 32-bit or 64-bit?
$ git --version --build-options

git version 2.47.1.windows.1
cpu: x86_64
built from commit: 2cd22437f64229935dc564db969cbcbfed5e9045
sizeof-long: 4
sizeof-size_t: 8
shell-path: D:/git-sdk-64-build-installers/usr/bin/sh
feature: fsmonitor--daemon
libcurl: 8.11.0
OpenSSL: OpenSSL 3.2.3 3 Sep 2024
zlib: 1.3.1

Older version git version 2.24.1.windows.2 do not had this problems.

  • Which version of Windows are you running? Vista, 7, 8, 10? Is it 32-bit or 64-bit?
$ cmd.exe /c ver

Microsoft Windows [Version 10.0.19045.5131]
  • 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:
Path Option: BashOnly
SSH Option: OpenSSH
Tortoise Option: false
CURL Option: OpenSSL
CRLF Option: CRLFCommitAsIs
Bash Terminal Option: MinTTY
Git Pull Behavior Option: FFOnly
Use Credential Manager: Enabled
Performance Tweaks FSCache: Enabled
Enable Symlinks: Disabled
Enable FSMonitor: Disabled

  • Any other interesting things about your environment that might be related
    to the issue you're seeing?

Added tmux with libs from libevent from msys2

Details

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

Bash with mintty

When using vim whole console get cleared, I boils down this problem to:

git config core.editor "f(){ echo $'\e[?1049h\e[22;0;0t'; echo \"Write to \$1\"; cat > \"\$1\"; echo $'\e[?1049l\e[23;0;0;t'; }; f"
git commit --amend
  • What did you expect to occur after running these commands?

I can see content in console like (all console history before commit):

[10:08][Yankes:~/prog/dummy] (master)
$ tmux

[11:08][Yankes:~/prog/dummy] (master)
$ vim

[12:08][Yankes:~/prog/dummy] (master)
$ git config core.editor "f(){ echo $'\e[?1049h\e[22;0;0t'; echo \"Write to \$1\"; cat > \"\$1\"; echo $'\e[?1049l\e[23;0;0;t'; }; f" && git commit --amend
hint: Waiting for your editor to close the file...
[master ea17ecf] eeee
 Date: Sat Dec 7 00:06:33 2024 +0100
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 foo
[12:13][Yankes:~/prog/dummy] (master)
$
  • What actually happened instead?

Lot of empty space and final commit result message:











hint: Waiting for your editor to close the file...
[t-feature/merge-appka c315b8b668] aaaa
 Date: Fri Dec 6 16:22:31 2024 +0100
 1 file changed, 1 insertion(+)
 create mode 100644 dummy
[12:13][Yankes:~/prog/dummy] (master)
$

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

No, clean repository is enough.

Overall vim have too some problems with gathering info about terminal and mess up my colors
when run through git.

@dscho
Copy link
Member

dscho commented Mar 3, 2025

f(){ echo $'\e[?1049h\e[22;0;0t'; echo \"Write to \$1\"; cat > \"\$1\"; echo $'\e[?1049l\e[23;0;0;t'; }; f

Isn't this more an issue for https://github.com/mintty/mintty?

Also, you assume quite a bit of context without trying to help any reader along should they lack that context. What are you trying to accomplish with the \e[?1049h/\e[?1049l sequences? And what with the \e[22;0;0t/\e[23;0;0t ones? I can see no description of them on https://github.com/mintty/mintty/wiki/CtrlSeqs, and I have to admit that I feel quite annoyed by the terseness of this issue description as well as the willingness to put quite the burden and time tax on anyone who dares to try to make any sense of this report. I find it very inconsiderate to write such a report that would require such a lot of research merely to understand what the bug report is trying to say.

@dscho dscho added the unclear label Mar 3, 2025
@Yankes
Copy link
Author

Yankes commented Mar 3, 2025

I do not think is problem with mintty as same happens under tmux and problem appear only after updating git version.

As for my example, template ask for minimal example, and I simply could have broken vim config that could interfere with git.
Therefore I extracted control codes that vim send to swap screens in xterm that work fine in other contexts but when git run vim something get confused.
I was hoping that two line example that allow reproduce bug is enough (as this exact code work on other machines with older git or diffret git distributions).
Its hard for me to add more context how its work as only thing I could provide some random pages I find when I look what escape codes vim output and make sense of this why it with git mess up my console.

As far I understand
\e[?1049h ask terminal to switch to temporary screen without scroll back (typical vim usage)
\e[?1049l ask terminal to go back to normal terminal screen with previous content (typical used by bash)
for \e[22;0;0t and \e[23;0;0;t I do not know what point of it is, simply vim output them. when I now remove it problem still presentient. I could probably reduce it more but as I could break git in less than 200 characters I thought this is minimal enough.

@dscho
Copy link
Member

dscho commented Mar 3, 2025

I cannot promise anything, but there is an off-chance that git-for-windows/msys2-runtime#87 might fix your problem. To test, 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?

@Yankes
Copy link
Author

Yankes commented Mar 3, 2025

After replacing msys dll it still behave same, but looking on description of that error it could be related.
I will maybe install fresh version too as I did not update it from time of report.

@TomasMalecek
Copy link

TomasMalecek commented Mar 5, 2025

I am facing the same issue even under different circumstances -- after using a pager, e.g., via git diff.

In my ~/.profile, I have export LESS=RS as I want the pager's content not to pollute the scrollback. After an update (sadly I am not sure about the original version), I started getting this weird behavior where a part of the previous scrollback content gets overwritten with blank space. It happens when Vim (core.editor) or Less (core.pager) are executed. When the scrollback is long enough, it can be seen that the top is OK and only the last several lines (whose number exactly matches the height of the window) are cleared.

By the way, while trying to quickly get some scrollback content, I came across a separate issue and reported it as #5468. The details of my setup are mentioned there. I also reproduced both issues on the latest snapshot (built from 1424e27), specifically its portable version.

@TomasMalecek
Copy link

I tried playing with the options in the LESS environment variable and with core.pager only to realize that when I execute less separately, directly on the command line, without Git, it does not exhibit this weird behavior.

@Yankes
Copy link
Author

Yankes commented Mar 7, 2025

I made experiment, and run git from cmd, and its look like it work here correctly.
Interesting when I pipe output it fix this behavior:

git commit --amend | cat

aside of butchering vim, it fix console clearing.

[ps]

another interesting thing is that when using tmux :pipe-pane to track what is send to terminal I see that git intercept my escape codes and manually clear whole console using \e[K codes. Maybe it get confused what $TERM is set now? at least my tmux report screen-256color.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants