summaryrefslogtreecommitdiffstats
path: root/git-base.sh
diff options
context:
space:
mode:
authorMichael Allen <michael@michaelallen.io>2015-03-09 11:48:49 +0000
committerMichael Allen <michael@michaelallen.io>2015-03-09 11:48:49 +0000
commit82f5bd7c9c9118f2e5b623860beee1c76e03cec0 (patch)
tree21b077bac2eef1dbd16985412c0fc73c45531b6f /git-base.sh
parentd95454d16ff21e860669287f194111367e3da9d2 (diff)
downloadgit-sonar-82f5bd7c9c9118f2e5b623860beee1c76e03cec0.tar.gz
git-sonar-82f5bd7c9c9118f2e5b623860beee1c76e03cec0.zip
prevent bad grep usage when no branch_name
Diffstat (limited to 'git-base.sh')
-rwxr-xr-xgit-base.sh14
1 files changed, 8 insertions, 6 deletions
diff --git a/git-base.sh b/git-base.sh
index 40f733b..2debafa 100755
--- a/git-base.sh
+++ b/git-base.sh
@@ -123,12 +123,14 @@ readable_branch_name() {
remote_branch_name() {
local localRef="$(branch_name)"
- local remoteBranch="$(git for-each-ref --format='%(upstream:short)' refs/heads $localRef 2>/dev/null | grep $localRef)"
- if [[ -n $remoteBranch ]]; then
- echo $remoteBranch
- return 0
- else
- return 1
+ if [[ -n "$localRef" ]]; then
+ local remoteBranch="$(git for-each-ref --format='%(upstream:short)' refs/heads $localRef 2>/dev/null | grep $localRef)"
+ if [[ -n $remoteBranch ]]; then
+ echo $remoteBranch
+ return 0
+ else
+ return 1
+ fi
fi
}