From e0e489945c48473b95284da2d84925d400dcc466 Mon Sep 17 00:00:00 2001 From: Michael Allen Date: Fri, 27 Feb 2015 17:07:27 +0000 Subject: optmise commits against functions by not checking if_tracking_remote --- git-base.sh | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'git-base.sh') 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 -- -- cgit v1.2.3