git root: show '.' when using with -r in the root dir (#995)

This commit is contained in:
罗泽轩 2022-10-06 13:56:07 +08:00 committed by GitHub
parent 62aa91f221
commit 584e0283f5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -6,7 +6,13 @@ git_root() {
# get the relative path of current path according to root of repo
git_root_relative() {
git rev-parse --show-prefix
rel=$(git rev-parse --show-prefix)
if [ -z "$rel" ]; then
# git rev-parse --show-prefix will output empty string when we are in the root dir
echo "."
else
echo "$rel"
fi
}
if test $# -eq 0; then