-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Native paths with backslashes do not work in $env:EDITOR #3822
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
Comments
I am afraid that this is incorrect. The backslash character is used as escape character in shell invocations, and like so many other programs,
I can think of two better workarounds:
I strongly prefer the first of these two. If you want a third workaround: Create the file #!/bin/sh
exec /c/tools/neovim/Neovim/bin/nvim.exe "$@" and use But as I said, |
It's assumed to be a shell command on unix, why would there be an assumption about a unix shell on Windows, that makes no sense. |
@rkitover many parts of Git assume that a Unix shell is present. It's just the reality I live in, I do not claim that it makes things easy. |
There is no standard as of yet for |
There is a standard, however, in the Unix ecosystem, from where Git hails. And if you want to introduce anything in the Windows world that is incompatible with the Unix version thereof, I am not interested 😁. |
I think I'd be able to come up with a fix for this that wouldn't introduce much incompatibility, it just needs to check if the first part is a path to a windows executable. |
No, that would introduce an inconsistency. Please do keep in mind that What you're arguing for is to introduce an incompatibility. |
@rimrul @phil-blain @PhilipOakley Any thoughts on this? |
I don't have a strong opinion as I'm not really using Git on Windows and I'm really new to Windows. What I do think is that in general there could be more documentation around how Git treats paths to programs on Windows. This here issue is about A note somewhere in the documentation (in |
Ultimately, this 'problem' (as I see it), is that Git (project) doesn't declare that it's raison d'etre is to be the SCM for Linux, which is what makes the assumption about using the unix shell syntax, and dir/path style, the 'sensible' option. The success of Git in eating the world does mean that Windows compatibility can be awkward at times, but unfortunately Git isn't going to stop being Linux (unix) focussed any time soon. I don't think we have a good plan/approach to documenting compatibility solutions so that all the good advice above can/could be collated into the [Git-for-Windows] version of the documentation. It would be nice if there was a way of shimming in a e.g. 'Compatibility' section in various man pages that would allow different OS's (Mac, Windows, Non-Stop) to provide guidance (such as above) so it become integrated into the project slightly more than the current wiki and other notes. [Aside: In a similar vein I'd also like the option of adding 'tutorial examples' to man pages to give newer users a help up, given that the man pages are in 'reference' style that presumes existing understanding of significant concepts] |
Is Git for Windows officially a project affiliated with Git itself? The focus here seems to be on your MSYS2 "git bash" stuff, which a lot of people for some reason like better than regular MSYS2 (for one thing the MSYS2 git port is not great.) But all of that stuff is horrible and a dead end. You said you don't want to maintain too much code for VS support, so you are admitting that this is a low priority for you. As we discussed in the other PR, the VS port currently does not even use the manifest, so VS binaries will be subtly wrong in their behavior whenever they do an OS build number check. I'll try to send a PR for that later. I'd like to see a more native focused fork, built with MSVC of course, and using native tools and shell etc. most of which are already available in choco. Rather than bringing along a very crappy port of unix. A good native port doesn't port the whole os along with the program, but aims to target native idioms and users. I probably don't have time to do something like that myself, but if some people are interested. It doesn't look like you're interested in this being a separate track for this project anyway.
I don't see how that makes things like this sensible, sorry. |
It's probably better to say that Git for Windows is closely affiliated with Git. Being 'Open Source' means there is more latitude in the arrangements. The Git for Windows project seeks to provide the Git capabilities, on Windows, which does put it in a leader-follower position. The Git for Windows compatibility shims and patches are continually rebased on top of the latest Git release, rather than GfW choosing which parts of the Git release to pull in.
MSYS2 is the basic shim to fit Git onto Windows. Some may have chosen CYGWIN in the past, but from one perspective that's just abdicating from the underlying platform. The MSYS2 (+ MinGW) is the half way house (worst of both world from some perspectives ;-). If folk want to start with MSYS2, and then add apps, such as Git, then it's their choice. But it doesn't put Git (i.e. distributing source code storage and versioning to users) first. Aside: I came to Git because I recognised it would solve my problem of personal source code versioning when writing exploratory Matlab code. The corporate offerings were too locked down. One feature of the Git setup is its expectation of posix shell scripting (aka Torvalds), as that is still used in some of the Git commands and in the test suite. So that's needed somehow, which results in using/choosing bash (other shells possible).
The problem is a) Fast Moving Target b) lack of resources (devs) c) false focus. There is only so much that can be done within Git for Windows without active support, and an appreciation of the long term maintenance load. Steering that course isn't easy. I'm grateful for what @dscho has done, often stuck between a rock and a hard place. |
Every time you judge someone, you reveal a part of yourself that needs healing.
It's not that it is a low priority. It's more that I do not want to maintain two essentially distinct products that do not need to be distinct in the first place.
There are performance issues with MSVC's In general, replacing a known component or toolchain with another one should be not only assessed looking for benefits, but also for risks. Ripping out the GCC toolchain and replacing it with an MSVC one bears a rather huge risk of introducing unwanted and unexpected problems. And I am not only talking about
See the comment above regarding judging someone.
Indeed. One promise of Git (and hence, of Git for Windows) is that hooks and aliases are executed via a POSIX shell. You can, of course, try to break that promise. It's up to the Git for Windows maintainer, however, to pay the price for that. And since I am the Git for Windows maintainer, that means I would have to pay the price for a goal that I do not even find particularly convincing ("avoid porting unix"; We are not actually porting Unix at all). As a consequence, out of sheer self-preservation I will dismiss every attempt to remove the requirement to run hooks and aliases (and commands like |
I meant the git package in MSYS2 not this project, I was not insulting your work.
Hooks and aliases are not even part of a git repo. There's also a native port of busybox for windows that will handle basic POSIX scripting where this is required for whatever reason. Things like simple bisect commands would even work in PowerShell as they are. Where is this requirement for a POSIX shell documented anyway?
conan has just about everything, as binary packages too. |
Yes, there is. There is also #1439.
Careful with such claims. https://github.com/git-for-windows/git/blob/v2.36.1.windows.1/git-bisect.sh is a shell script that would not work in PowerShell unless you launch a POSIX shell (which is arguably not "working in PowerShell").
It's an implicit requirement:
Nothing and nobody is stopping you from trying to move Git for Windows over to conan. From experience, I'd expect that to take about 4-5 months. That's how long it took me in 2015 to move Git for Windows from MSys to MSYS2. |
I would assume a user would want the shell that they actually use, and are aware of that fact.
Most of which have nothing to do with Git itself and are obviously for bash which a user can run in MSYS2/WSL/Cygwin/etc..
If a user is not aware of the shell that they are currently using, they deserve all the frustration that they get.
I was not suggesting any such thing. The original issue was
My interest is in the git command working properly in powershell, a proper windows port would be nice, but I have enough to do without taking that on. This is what my original issue was about, and at least that is fixed. On this subject, I spent considerable effort making some improvements to the cmake code, and you said you don't want to "maintain a 100 line function" which is by far one of the most insulting code reviews I've ever seen. Nevertheless I'll try to finish that PR and look at the manifest issue. Relying on a manifest for code compatibility instead of making it run on the current OS is another thing I wouldn't do. |
Neither CMD nor PowerShell are a shell. Besides, your suggestion to change this now would literally break existing setups. Like thousands. Maybe even hundreds of thousands. Nobody can sincerely expect me to do that.
I dislike this language, as I perceive it as presumptuous and unnecessarily incendiary, and would like to ask you to word your responses more carefully and more kindly. Apart from that, I guess I will repeat this point again: This is so well-established, for well over a decade, that I am puzzled that there is any uncertainty about how fixed in stone this is.
That is not what I said, and given that I maintain many, many functions that are well over 100 lines long, it should be obvious that even if had I said it, it is not what I would have meant. I maintain code, even complex code, when there is a good justification for the complexity. In the CMake case, I just did not see the need to interpret environment variables in Git's CMake definition when regular CMake cache entries (think: I might be wrong about that conclusion. There might be a compelling reason why a developer who wishes to build Git via the CMake definition should be unable to set or modify those CMake cache entries, and that in such an instance there would somehow exist a convenient way to set environment variables scoped to that very same build process instead. It does not sound very likely to me that such a compelling reason exists, and if it does, I am certainly not yet privy to it. If it exists, I definitely would love to learn about it. |
They are scripting interpreters that make it convenient to run external binaries/scripts. In fact, PowerShell runs very well on Linux, and can perform all the functions of other Linux shells such as being your login shell, etc. etc.. A cursory look at the git sources indicates that it expects Of course, that doesn't stop someone from using non-POSIX bash syntax in an alias for example, so you aren't guaranteeing universal compatibility. In any case, support for other shells for aliases would have to be handled upstream, if anyone has any interest in that.
I never suggested this, and it would not break anything presuming the alias shell is configurable. Some people might have an interest in using other shells for their aliases, such as zsh, tcsh or nushell or whatever, bash is not the only shell that exists. But this looks like an upstream project for anyone who has an interest in it.
It would be reasonable to expect a concept to match the OS, regardless of where it is inherited from, like the OS representation of paths. You might want to do something like this in your PowerShell profile: $env:EDITOR = (get-command nvim).source , but this doesn't work with Git, so you have to do something like: $env:EDITOR = (get-command nvim).source -replace '\\','/' , which is still a valid Windows path fortunately, but should not be necessary. Under the UNIX semantics for Git, Your example of e.g. $env:EDITOR = "C:\code\code -someparam" , would also work fine. In the case of simple commands such as this, shell interpretation should not even be necessary, regardless of choice of shell. So I would argue that this is a bug from the perspective of preserving the UNIX semantics in Git for Windows as well. PowerShell also natively supports
Let's continue this in the relevant thread. |
Python is also a scripting interpreter. So is node.js.
You suggested precisely that, by suggesting to let something else than a POSIX-compliant shell handle the Quite honestly, it defies my sense of logic why we are still discussing this. |
You have not responded to my other points, namely that the first attempt to expand an |
See around line 830 in run-command.c. |
The idea is that |
The cases in this issue are in fact trivial cases and would work fine via direct execution, but DO NOT work with a POSIX shell. |
Setup
defaults?
to the issue you're seeing?
Using PowerShell core and Windows Terminal as environment.
Details
Using Windows Terminal with PowerShell core 7.2.2.
Minimal, Complete, and Verifiable example
this will help us understand the issue.
As discussed in #3629, for which this is a followup:
Git to start editor for editing commit message.
Workaround for now:
this encloses the path in single quotes, which works fine in Git bash.
The text was updated successfully, but these errors were encountered: