{"action":"created","issue":{"url":"https://api.github.com/repos/git-for-windows/git/issues/402","labels_url":"https://api.github.com/repos/git-for-windows/git/issues/402/labels{/name}","comments_url":"https://api.github.com/repos/git-for-windows/git/issues/402/comments","events_url":"https://api.github.com/repos/git-for-windows/git/issues/402/events","html_url":"https://github.com/git-for-windows/git/issues/402","id":107004596,"number":402,"title":"\"cannot be used without a working tree.\" errors","user":{"login":"living180","id":425650,"avatar_url":"https://avatars.githubusercontent.com/u/425650?v=3","gravatar_id":"","url":"https://api.github.com/users/living180","html_url":"https://github.com/living180","followers_url":"https://api.github.com/users/living180/followers","following_url":"https://api.github.com/users/living180/following{/other_user}","gists_url":"https://api.github.com/users/living180/gists{/gist_id}","starred_url":"https://api.github.com/users/living180/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/living180/subscriptions","organizations_url":"https://api.github.com/users/living180/orgs","repos_url":"https://api.github.com/users/living180/repos","events_url":"https://api.github.com/users/living180/events{/privacy}","received_events_url":"https://api.github.com/users/living180/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-09-17T15:00:29Z","updated_at":"2015-09-17T16:48:59Z","closed_at":null,"body":"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:\r\n\r\n* set up `rb` as an alias for `rebase`\r\n* run MSYS bash:  `C:\\mingw\\msys\\1.0\\bin\\bash.exe --login -i`\r\n* on a branch which has diverged from its upstream branch, run `git rb`\r\n\r\nI then get the following output:\r\n\r\n    First, rewinding head to replay your work on top of it...\r\n    fatal: C:\\git-sdk-64\\mingw64/libexec/git-core/git-am cannot be used without a working tree.\r\n\r\nThe 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 f7b4bf23f21cb60f3c08fab3a394bfea725f7fdf.  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.\r\n\r\nI'm not sure exactly how this needs to be fixed, but I'm happy to help with debugging or with testing patches."},"comment":{"url":"https://api.github.com/repos/git-for-windows/git/issues/comments/141145535","html_url":"https://github.com/git-for-windows/git/issues/402#issuecomment-141145535","issue_url":"https://api.github.com/repos/git-for-windows/git/issues/402","id":141145535,"user":{"login":"dscho","id":127790,"avatar_url":"https://avatars.githubusercontent.com/u/127790?v=3","gravatar_id":"","url":"https://api.github.com/users/dscho","html_url":"https://github.com/dscho","followers_url":"https://api.github.com/users/dscho/followers","following_url":"https://api.github.com/users/dscho/following{/other_user}","gists_url":"https://api.github.com/users/dscho/gists{/gist_id}","starred_url":"https://api.github.com/users/dscho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dscho/subscriptions","organizations_url":"https://api.github.com/users/dscho/orgs","repos_url":"https://api.github.com/users/dscho/repos","events_url":"https://api.github.com/users/dscho/events{/privacy}","received_events_url":"https://api.github.com/users/dscho/received_events","type":"User","site_admin":false},"created_at":"2015-09-17T16:48:59Z","updated_at":"2015-09-17T16:48:59Z","body":"> run MSYS bash:  C:\\mingw\\msys\\1.0\\bin\\bash.exe --login -i\r\n\r\nWhy? Why not the Git Bash?\r\n\r\n> is_inside_dir ends up getting called with a path starting with a lowercase drive letter\r\n\r\nI am almost 100% certain that Git Bash would return a path starting with an upper-case drive letter... But not MSys1 Bash... You could say that Git for Windows 2.x is compatible only with the MSys2 Bash (because it ships with it) but not with an MSys1 Bash..."}}