Description
Since upgrading to Git for Windows v2.5.2 from v2.5.0, I've been running into fatal: <git-command> cannot be used without a working tree.
errors in certain cases. It only seems to occur when the initial command invoked was a git alias. It also does not occur when I use the Git SDK shell (I normally use bash from MSYS - not MSYS2) One way to reproduce it:
- set up
rb
as an alias forrebase
- run MSYS bash:
C:\mingw\msys\1.0\bin\bash.exe --login -i
- on a branch which has diverged from its upstream branch, run
git rb
I then get the following output:
First, rewinding head to replay your work on top of it...
fatal: C:\git-sdk-64\mingw64/libexec/git-core/git-am cannot be used without a working tree.
The error results from the fact that when git am
invoikes git rev-parse --is-inside-work-tree
it incorrectly prints false
instead of true
. I bisected the issue to f7b4bf2. There are no symlinks involved in my case, so the only change is that normalize_ntpath
is now called on dirname
before it is passed to _wchdir
. The only transformation that normalize_ntpath
is actually performing in my case is replacing backlashes with forward slashes. When that transformation is in place, is_inside_dir
ends up getting called with a path starting with a lowercase drive letter, while xgetcwd
returns a path with an uppercase drive letter, causing dir_inside_of
to return -1
. However, if I remove the backslash transformation from normalize_ntpath
, is_inside_dir
gets called with an uppercase drive letter path and everything works fine.
I'm not sure exactly how this needs to be fixed, but I'm happy to help with debugging or with testing patches.