summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Allen <michael@michaelallen.io>2015-02-27 17:07:27 +0000
committerMichael Allen <michael@michaelallen.io>2015-02-27 17:07:27 +0000
commite0e489945c48473b95284da2d84925d400dcc466 (patch)
tree4f2fe552d62e7238eebbe789ca6853fba97c4b87
parent43fea9ca9a7ab2d0e4a774eab7c1b13d49f70cc8 (diff)
downloadgit-sonar-e0e489945c48473b95284da2d84925d400dcc466.tar.gz
git-sonar-e0e489945c48473b95284da2d84925d400dcc466.zip
optmise commits against functions by not checking if_tracking_remote
-rwxr-xr-xgit-base.sh20
1 files changed, 12 insertions, 8 deletions
diff --git a/git-base.sh b/git-base.sh
index 13d31d7..198a335 100755
--- a/git-base.sh
+++ b/git-base.sh
@@ -148,9 +148,10 @@ remote_branch_name() {
}
commits_behind_of_remote() {
- if is_tracking_remote; then
+ remote_branch="$(remote_branch_name)"
+ if [[ -n "$remote_branch" ]]; then
set --
- set -- $(git rev-list --left-right --count $(remote_branch_name)...HEAD)
+ set -- $(git rev-list --left-right --count ${remote_branch}...HEAD)
behind=$1
ahead=$2
set --
@@ -161,9 +162,10 @@ commits_behind_of_remote() {
}
commits_ahead_of_remote() {
- if is_tracking_remote; then
+ remote_branch="$(remote_branch_name)"
+ if [[ -n "$remote_branch" ]]; then
set --
- set -- $(git rev-list --left-right --count $(remote_branch_name)...HEAD)
+ set -- $(git rev-list --left-right --count ${remote_branch}...HEAD)
behind=$1
ahead=$2
set --
@@ -174,9 +176,10 @@ commits_ahead_of_remote() {
}
remote_behind_of_master() {
- if is_tracking_remote; then
+ remote_branch="$(remote_branch_name)"
+ if [[ -n "$remote_branch" ]]; then
set --
- set -- $(git rev-list --left-right --count origin/master...$(remote_branch_name))
+ set -- $(git rev-list --left-right --count origin/master...${remote_branch})
behind=$1
ahead=$2
set --
@@ -187,9 +190,10 @@ remote_behind_of_master() {
}
remote_ahead_of_master() {
- if is_tracking_remote; then
+ remote_branch="$(remote_branch_name)"
+ if [[ -n "$remote_branch" ]]; then
set --
- set -- $(git rev-list --left-right --count origin/master...$(remote_branch_name))
+ set -- $(git rev-list --left-right --count origin/master...${remote_branch})
behind=$1
ahead=$2
set --