Git BASH for Windows "Not inside top level dir" warning
cesarcoatl opened this issue · 1 comments
Is your feature request related to a problem? Please describe.
I have installed Git for Windows which comes with Git BASH, and ugit
prints a warning when executed at the top-level directory of the working tree.
$ mkdir ~/git-repo
$ cd ~/git-repo
$ git init
$ ugit
ugit: Not inside top level dir C:/Users/thecesrom/git-repo
Undo your last oopsie in Git 🙈️
Press ctrl+c to exit anytime
This is because in Git BASH for Windows $(pwd)
is a "UNIX" path, and git rev-parse --show-toplevel
is a Windows path.
$ pwd
/c/Users/thecesrom/git-repo
$ git rev-parse --show-toplevel
C:/Users/thecesrom/git-repo
Describe the solution you'd like
After reading Git's documentation for rev-parse
I have found a suitable option, and I have a PR #22 ready if you're interested.
In this case git rev-parse --show-cdup
is a suitable alternative.
--show-cdup
When the command is invoked from a subdirectory, show the path of the top-level directory relative to the current directory (typically a sequence of "../", or an empty string).
See: https://git-scm.com/docs/git-rev-parse#Documentation/git-rev-parse.txt---show-cdup
git rev-parse --show-cdup
will only return an empty string if we are at the top-level directory.
$ cd ~/git-repo
$ mkdir -p sub/dir/ect/ory
$ cd sub/dir/ect/ory
$ git rev-parse --show-cdup
../../../../
$ cd ~/git-repo
$ git rev-parse --show-cdup
Describe alternatives you've considered
None.
Additional context
N/A