summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xgit-sonar46
1 files changed, 20 insertions, 26 deletions
diff --git a/git-sonar b/git-sonar
index 0cd53be..fa2237e 100755
--- a/git-sonar
+++ b/git-sonar
@@ -85,21 +85,17 @@ remote_branch_name() {
}
commits_behind_of_remote() {
- remote_branch=${1:-"$(remote_branch_name)"}
- if [ -n "$remote_branch" ]; then
- git rev-list --left-only --count "${remote_branch}...HEAD" 2>/dev/null
- else
- printf '%s' "0"
- fi
+ remote_branch="$1"
+ [ -n "$remote_branch" ] \
+ && git rev-list --count "HEAD..${remote_branch}" 2>/dev/null \
+ || printf '0\n'
}
commits_ahead_of_remote() {
- remote_branch=${1:-"$(remote_branch_name)"}
- if [ -n "$remote_branch" ]; then
- git rev-list --right-only --count "${remote_branch}...HEAD" 2>/dev/null
- else
- printf '%s' "0"
- fi
+ remote_branch="$1"
+ [ -n "$remote_branch" ] \
+ && git rev-list --count "${remote_branch}..HEAD" 2>/dev/null \
+ || printf '0\n'
}
determine_tracked_remote() {
@@ -113,23 +109,21 @@ determine_tracked_remote() {
}
remote_behind_of_master() {
- remote_branch=${1:-"$(remote_branch_name)"}
- tracked_remote=$(determine_tracked_remote)
- if [ -n "$remote_branch" ] && [ "$remote_branch" != "$tracked_remote" ]; then
- git rev-list --left-only --count "${tracked_remote}...${remote_branch}" 2>/dev/null || printf '%s' "0"
- else
- printf '%s' "0"
- fi
+ remote_branch="$1"
+ tracked_remote="$(determine_tracked_remote)"
+ [ -n "$remote_branch" ] \
+ && [ "$remote_branch" != "$tracked_remote" ] \
+ && git rev-list --count "${remote_branch}..${tracked_remote}" 2>/dev/null \
+ || printf '0\n'
}
remote_ahead_of_master() {
- remote_branch=${1:-"$(remote_branch_name)"}
- tracked_remote=$(determine_tracked_remote)
- if [ -n "$remote_branch" ] && [ "$remote_branch" != "$tracked_remote" ]; then
- git rev-list --right-only --count "${tracked_remote}...${remote_branch}" 2>/dev/null || printf '%s' "0"
- else
- printf '%s' "0"
- fi
+ remote_branch="$1"
+ tracked_remote="$(determine_tracked_remote)"
+ [ -n "$remote_branch" ] \
+ && [ "$remote_branch" != "$tracked_remote" ] \
+ && git rev-list --count "${tracked_remote}..${remote_branch}" 2>/dev/null \
+ || printf '0\n'
}
# Diacritic marks for overlaying an arrow over A D C etc