diff options
Diffstat (limited to 'radar-base.sh')
-rwxr-xr-x | radar-base.sh | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/radar-base.sh b/radar-base.sh index b5a7df9..649978f 100755 --- a/radar-base.sh +++ b/radar-base.sh @@ -264,9 +264,19 @@ commits_ahead_of_remote() { fi } +determine_tracked_remote() { + by_branch=$(git config --local branch."$(git rev-parse --abbrev-ref HEAD)".git-radar-tracked-remote) + [[ ! -z $by_branch ]] && echo $by_branch && return 0 + + by_config=$(git config --local git-radar.tracked-remote) + [[ ! -z $by_config ]] && echo $by_config && return 0 + + echo "origin/master" +} + remote_behind_of_master() { remote_branch=${1:-"$(remote_branch_name)"} - tracked_remote="origin/master" + 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 @@ -276,7 +286,7 @@ remote_behind_of_master() { remote_ahead_of_master() { remote_branch=${1:-"$(remote_branch_name)"} - tracked_remote="origin/master" + 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 @@ -337,6 +347,7 @@ staged_status() { local filesDeleted="$(printf '%s' "$gitStatus" | grep -oE "D[AMCR ] " | wc -l | grep -oEi '[1-9][0-9]*')" local filesRenamed="$(printf '%s' "$gitStatus" | grep -oE "R[AMCD ] " | wc -l | grep -oEi '[1-9][0-9]*')" local filesCopied="$(printf '%s' "$gitStatus" | grep -oE "C[AMDR ] " | wc -l | grep -oEi '[1-9][0-9]*')" + local typeChanged="$(printf '%s' "$gitStatus" | grep -oE "T[AMDR ] " | wc -l | grep -oEi '[1-9][0-9]*')" if [ -n "$filesAdded" ]; then staged_string="$staged_string$filesAdded${prefix}A${suffix}" @@ -353,6 +364,9 @@ staged_status() { if [ -n "$filesCopied" ]; then staged_string="$staged_string$filesCopied${prefix}C${suffix}" fi + if [ -n "$typeChanged" ]; then + staged_string="$staged_string$typeChanged${prefix}TC${suffix}" + fi printf '%s' "$staged_string" } @@ -386,6 +400,7 @@ unstaged_status() { local filesModified="$(printf '%s' "$gitStatus" | grep -oE "[ACDRM ]M " | wc -l | grep -oEi '[1-9][0-9]*')" local filesDeleted="$(printf '%s' "$gitStatus" | grep -oE "[AMCR ]D " | wc -l | grep -oEi '[1-9][0-9]*')" + local typeChanged="$(printf '%s' "$gitStatus" | grep -oE "[AMDR ]T " | wc -l | grep -oEi '[1-9][0-9]*')" if [ -n "$filesDeleted" ]; then unstaged_string="$unstaged_string$filesDeleted${prefix}D${suffix}" @@ -393,6 +408,9 @@ unstaged_status() { if [ -n "$filesModified" ]; then unstaged_string="$unstaged_string$filesModified${prefix}M${suffix}" fi + if [ -n "$typeChanged" ]; then + unstaged_string="$unstaged_string$typeChanged${prefix}TC${suffix}" + fi printf '%s' "$unstaged_string" } @@ -405,7 +423,7 @@ untracked_status() { local filesUntracked="$(printf '%s' "$gitStatus" | grep "?? " | wc -l | grep -oEi '[1-9][0-9]*')" if [ -n "$filesUntracked" ]; then - untracked_string="$untracked_string$filesUntracked${prefix}A${suffix}" + untracked_string="$untracked_string$filesUntracked${prefix}?${suffix}" fi printf '%s' "$untracked_string" } @@ -542,12 +560,12 @@ is_cwd_a_dot_git_directory() { elif [[ -z $1 ]]; then return 1 else - is_cwd_a_dot_git_directory ${1%/*} + is_cwd_a_dot_git_directory "${1%/*}" fi } stash_status() { - if ! is_cwd_a_dot_git_directory $PWD; then + if ! is_cwd_a_dot_git_directory "$PWD"; then local number_stashes="$(stashed_status)" if [ $number_stashes -gt 0 ]; then printf $PRINT_F_OPTION "${number_stashes}${COLOR_STASH}≡${RESET_COLOR_STASH}" |