Skip to content

Commit 584e028

Browse files
authored
git root: show '.' when using with -r in the root dir (#995)
1 parent 62aa91f commit 584e028

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

bin/git-root

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@ git_root() {
66

77
# get the relative path of current path according to root of repo
88
git_root_relative() {
9-
git rev-parse --show-prefix
9+
rel=$(git rev-parse --show-prefix)
10+
if [ -z "$rel" ]; then
11+
# git rev-parse --show-prefix will output empty string when we are in the root dir
12+
echo "."
13+
else
14+
echo "$rel"
15+
fi
1016
}
1117

1218
if test $# -eq 0; then

0 commit comments

Comments
 (0)