summaryrefslogtreecommitdiffstats
path: root/git-base.sh
diff options
context:
space:
mode:
authorMichael Allen <michael@michaelallen.io>2015-06-03 15:52:13 +0100
committerMichael Allen <michael@michaelallen.io>2015-06-03 15:52:21 +0100
commit48f5934b702510f116d19956c14f85ab35ba85fa (patch)
tree93ef7e23f38a395288e00f1f4e34315a8e9e6791 /git-base.sh
parent68fa32350114852188161c7ab96e5e493aaa6e12 (diff)
downloadgit-sonar-48f5934b702510f116d19956c14f85ab35ba85fa.tar.gz
git-sonar-48f5934b702510f116d19956c14f85ab35ba85fa.zip
fixed issue with branches that contain other branch names
When a remote branch begins with or ends with the local branch name then the commits against diff functions can report the commits for the remote branch instead of your local branch, e.g.: I have local branch `foo` with 1 commit ahead of master and a remote branch `foobar` with 2 ahead of master. The prompt will report 2 commits instead of the true 1 commit because the `grep $branch_name` returns the `foobar` branch. Simple fix is to ensure we grep for the full `/<branch_name>$` so: branch_name = `foo` `origin/foo` matches `other/foo` matches `origin/foobar` doesn't match `origin/barfoo` doesn't match
Diffstat (limited to 'git-base.sh')
-rwxr-xr-xgit-base.sh2
1 files changed, 1 insertions, 1 deletions
diff --git a/git-base.sh b/git-base.sh
index 950422d..eb91fc8 100755
--- a/git-base.sh
+++ b/git-base.sh
@@ -122,7 +122,7 @@ readable_branch_name() {
}
remote_branch_name() {
- local localRef="$(branch_name)"
+ local localRef="\/$(branch_name)$"
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