summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Holmboe <richard@holmboe.org>2016-09-28 14:48:17 +0200
committerRichard Holmboe <richard@holmboe.org>2016-09-28 14:48:17 +0200
commit9af949b6bd2969dc82a12ef3f143f2b2d446f03b (patch)
treebdf5e264f80ca82351643f952f365d3c90a6eb4c
parentc67d6bcd88c9073bc072af1cb13d7bfa85cbbbb0 (diff)
downloadgit-sonar-9af949b6bd2969dc82a12ef3f143f2b2d446f03b.tar.gz
git-sonar-9af949b6bd2969dc82a12ef3f143f2b2d446f03b.zip
Added additional checks for .git and sub-directories. This patch also includes using POSIX native commands and going away from basename/dirname
-rwxr-xr-xradar-base.sh10
1 files changed, 8 insertions, 2 deletions
diff --git a/radar-base.sh b/radar-base.sh
index a9e3a7f..b5a7df9 100755
--- a/radar-base.sh
+++ b/radar-base.sh
@@ -537,11 +537,17 @@ stashed_status() {
}
is_cwd_a_dot_git_directory() {
- [[ "$(basename $PWD)" == ".git" ]]; return $?
+ if [[ "${1##*/}" == ".git" ]]; then
+ return 0
+ elif [[ -z $1 ]]; then
+ return 1
+ else
+ is_cwd_a_dot_git_directory ${1%/*}
+ fi
}
stash_status() {
- if ! is_cwd_a_dot_git_directory; then
+ if ! is_cwd_a_dot_git_directory $PWD; then
local number_stashes="$(stashed_status)"
if [ $number_stashes -gt 0 ]; then
printf $PRINT_F_OPTION "${number_stashes}${COLOR_STASH}≡${RESET_COLOR_STASH}"