-
Notifications
You must be signed in to change notification settings - Fork 410
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
🐛 git add -p uncoloured in Windows Terminal in Git for Windows 2.38+ #1318
Comments
Sadly, the workaround (#1114 (comment)) doesn't work anymore with Git 2.40, because
|
I've found this thread while searching for an issue with git add -p (version 2.40.1.windows.1). Using I tracked the issue to this configuration in git:
It seems to work fine only with git's built-in tty terminal but the hanging is reproducible with Windows Terminal, Alacritty and conhost.exe. I tried with another computer that has git |
Also searched around and found this, and wanted to report my findings. I see the same thing in Windows Terminal (1.16.10262.0, Windows 11) and git version 2.40.1.windows.1, where the terminal hangs when doing It does not hang in the Git Bash external application, but the colors are still incorrect:
|
Seeing the same here 😢
|
Hi all, problems on Windows are either due to the terminal emulator, or to an old version of So, is it the terminal emulator that is the problem? Can you run it in something else, like Alacritty, and report back on whether that works? EDIT: Sorry I see now that the hanging was reproduced in Alacritty. Hm! Is it 24-bit colors that are causing the problems? Can you try cc @helmesjo |
I wonder whether the git-for-windows mailing list might be worth trying https://groups.google.com/g/git-for-windows. |
@dandavison I've checked some of the things you mentioned. Just for clarification about the terminal emulators:
Git v2.40.1.windows.1 comes with less v629. I've updated less manually with a more recent binary (v633) and the issue still reproduces. For comparison I've checked the less version that comes with Ubuntu 22.04 (WSL) and that's v590. In Ubuntu the issue is not reproducible.
The issue is with interactive mode but I don't know if git uses @dandavison Is here where I need to add
Adding I also found that you can escape the hang with ctrl-z (I imagine being windows it kills the process as it can't be recovered with Delta version 0.16.5 |
Wow, nice investigation @eduardo-sm, thanks for that. (I don't have a Windows machine to test on). So this seems quite non-obvious. This seems like a possible clue / starting point:
I have no reason to think this would work but I'm curious whether if you created a perl (or bash) script that simply passes stdin on to delta, whether that might (for some reason!) work? So I guess with bash that could simply be
where
|
Can you also try
|
Here are the results. Wrapping delta in a script and use it as follows still reproduces the issue. [interactive]
diffFilter = bash /tmp/delta.sh Although I'm not the one who uses For the second attempt with [interactive]
diffFilter = delta --color-only --paging=never It still reproduces the issue. On a final note, I noticed that using |
Just a note (as I haven’t found the time to re-test this on my end yet and am still using Git 2.39 instead):
In Windows consoles, Ctrl-Z doesn’t act like a suspend signal (I don’t think one exists at all) but commonly signifies end-of-file, when Microsoft’s C library is used to read the input. Typically (e. g. in Python’s REPL), you have to type Ctrl-Z + Enter on a line of its own where in Unix you’d press Ctrl-D, and the Ctrl-Z stays visible on screen as |
I found something new. Looking for
Depending on the version of less I got different results.
I'm not entirely sure on the differences but this may help to identify the issue. |
OK, so if you configure delta to use those 3 less versions (e.g. (Also does |
No, delta hangs with the 3 versions of less |
Regarding I now tried to wrap delta --color-only and a perl script system("delta", "--color-only"); And both of them behaved just as if placing The point I wanted to make with diff-highlight was mostly that it is still possible to redirect and recolor in at least some way with the newer git, so the interactive add was not breaking all redirection at least. |
So the current conclusion seems to be that the Windows version of Git is, for Could you try
? bat is, like delta, a Rust executable, and they are written in a similar way to a certain extent. I've tested that and it works for me on MacOS (you shouldn't get the "Your filter must maintain a one-to-one correspondence" error because bat emits un-decorated output when it is writing to a pipe, as is the case when invoked under |
@dandavison I tried with bat v0.23.0 (871abd2) |
Hmm. @th1000s this is a bit mysterious -- any ideas? Could it be something to do with |
I just tried using winpty and it works ( Tested usage
Using |
Could this be Windows 11 specific? Using 10 and conhost/cmd.exe or the VSCode builtin terminal (which starts powershell) I could not reproduce this with git 2.41.0 from (gitforwindows.org), nor with the Portable Git 2.40 one. |
@th1000s I've tried on windows 10 and the issue is reproducible there. What I meant by conhost is conhost running the bash shell from git for windows. The issue is not reproducible in Out of curiosity I tried with the build-in terminal from vscode and it also reproduces the issue using the bash shell from git for windows. |
I see, bash inside conhost is quite a QoL improvement, and I can reproduce it now. When the The good news: It's not delta. The bad news: This is triggered by a simple What does not hang for me:
I expected How do PortableGit binaries work for you, and could somebody check if [1] reproduces this? 1: use std::io::{Write, Read};
fn main() -> std::io::Result<()> {
let mut reader = std::io::stdin();
let mut buffer = Vec::new();
reader.read_to_end(&mut buffer)?;
std::io::stdout().write_all(&buffer)?;
Ok(())
} 2: fn main() -> std::io::Result<()> {
let data = "diff --git a/foo b/foo
index 8baef1b..5f5521f 100644
--- a/foo
+++ b/foo
@@ -1 +1,2 @@
abc
+def";
println!("{}", data);
// std::io::stdout().write_all(&data[..])?; // OR (+ Write import, and data = b"diff..."): also hangs
Ok(())
} |
It very much looks related to this git-for-windows / MYS2 issue git-for-windows/git#4422 and it seems the dev is still wrangling with it: git-for-windows/git#4464. |
@th1000s I tried using a script Note that using the script with the correct shebang doesn't show colors: Full delta.sh script: #!/bin/bash
delta --color-only |
I tried some more in Git Bash in Windows Terminal, not sure if it is still helpful or not.
So for me it seems like invoking some form of bash hangs it? |
Interesting. I used an absolute path for the Results:
The shebang
The shebang |
Huh, yeah I see the same thing, tested with absolute path now. |
The git-for-windows developer has pushed a possible fix (referenced in the first issue there), so this might be resolved in the next version. |
Can git-for-windows/git#4466 be related? Since this and that are eerily similar, I can't help but think that all these issues can be traced to a single root cause. I believe that, just like in the link above, reverting Git to 2.36.1 will temporarily remedy the problem. |
I'm going to close this issue, but that's not at all meant to stop the conversation (which is fascinating!) but rather to reflect the fact that the conversation has shown that this isn't a delta bug and so it's clearer to have the issue in closed state. |
I’m not seeing any new fixes in the two issues you linked above (4422 and 4464). Could you clarify where to look? And everyone, do you think we may have multiple issues here? One is the hang, another is the grey background when the hang doesn’t happen, and then there’s the complete lack of colour that I originally reported. They may or may not have a common cause, but if it’s something about pipes and blocking, I wouldn’t expect it to affect colours 🤔 |
I hope everyone found a workaround which works for them. And as astiob mentioned - the strange color background is so far unexplained, maybe it is another side effect. Issue git-for-windows/git#4422 mentions a new revert-commit (dscho/msys2-runtime@10e99fe). Also, in the other issue the reporter has posted a minimal reproducer in C++. |
Another strange Windows thing, sorry!
I upgraded Git for Windows from some older version (I can’t see which it was any more, sorry) to 2.39.2 (the latest available via winget) (git --version says “2.39.2.windows.1”), and now
git add -p
shows a plain diff that is completely uncoloured within hunks. The workaround from #1114 helps:but it is supposed to be unnecessary since Git 2.38. Moreover, in mintty (Git Bash) it works fine without the workaround:
Stranger still, it works in Windows Terminal if I use MSYS2’s git instead of Git for Windows, but then I get strange colours in non-interactive diffs:
Maybe there’s another bug in Git’s new interactive add, or maybe there’s one in Delta, or maybe even in Windows Terminal. What can I do to debug this?
I don’t see any visible difference (with Delta disabled) between the “native” and “non-native” interactive adds, and if I set the
diffFilter
totee myfile
, the files I get with Delta on and off are identical. And unlike in the Git 2.37 issue reports, I don’t get any error message: the output is just uncoloured; but then again, I tried installing 2.37 just to check, and I still didn’t see any error message (maybe it depended on the exact diff or repo structure).Using Windows Terminal 1.16.10262.0 on Windows 11 22H2 (the current version of both).
The text was updated successfully, but these errors were encountered: