Closed c00t closed 4 months ago
Since #370 is marked as no-planned-fix
, pull request still needed? Or just a quick fix in your planned commit?
After restoring my hooks to their original state (without the full path workaround I had been using), I deleted my local Path variable and added PATH and re-ran one of my failing test cases. The hook git branchless was able to find git correctly and everything seemed to work. Nice find, C00t! Is someone who has git-branchless set up for development able to make a PR for this? I guess I could... but I'd have to figure out how to get Rust set up for development again.
@AaronLieberman I've done a quick fix in my fork, and if you use cargo you can install it using below command. But I'm not sure if this fix is correct (i.e., only modifying the implementation of the run_hook
function) and if such a small modification would need to be merged as a PR.
cargo install --git https://github.com/c00t/git-branchless -f
A workaround for this bug is to create and execute a file fix-path.cmd
with the following contents
@echo off
set OLDPATH=%PATH%
set PATH=
set PATH=%OLDPATH%
set OLDPATH=
@arxanas @c00t's fix works for me. I tested it locally based on that branch and it's working for me on Windows as well on Ubuntu on WSL2. It looks like quite a safe change as from the code it looks like it wouldn't affect non-Windows platforms. Having this in the mainline would be a big improvement so that Windows would work reliably.
Would you be able to merge it into mainline? I tried to open up a PR for it but I'm not in the contributors group so it wouldn't let me. This change fixes issues #1256, #370, and #1144.
@c00t can you open a PR, or a otherwise affirmatively state that your code is fine to merge under the git-branchless license?
@arxanas done #1267
I do a lot of game engine programming so i can't avoid using git under native windows. When using git-branchless, I also had similar problem as (#370 , #1144 ). Begin debugging...
In #370
No, This is not a Git for Windows problem, after I debugged it, I realized that it is due to the naming of the
Path
environment variable, in the following code,git-branchless
reads the environment variable namedPATH
, but in windows, the variable name should bePath
.https://github.com/arxanas/git-branchless/blob/e7c3653c5e42f67a967d30ea57ded5a34cc6f9aa/git-branchless-lib/src/git/run.rs#L407-L422
I believe this is due to the fact that the windows shell is insensitive to the case of environment variable names (both pwsh and cmd), which many developers don't pay attention to on windows, you can read the environment variables correctly in the shell with
Path
PATH
or evenPaTh
.quick fix:
yep, windows target's
std
crate also:Originally posted by @c00t in https://github.com/arxanas/git-branchless/issues/370#issuecomment-1971239404