Merge pull request #179 from ogr3/dots-fix

Possible to have dots in branch name
master
Martin Gondermann 10 years ago
commit 4f6c446220
  1. 24
      gitstatus.sh

@ -27,7 +27,7 @@ num_untracked=0
while IFS='' read -r line || [[ -n "$line" ]]; do
status=${line:0:2}
case "$status" in
\#\#) branch_line="$line" ;;
\#\#) branch_line="${line/\.\.\./^}" ;;
?M) ((num_changed++)) ;;
U?) ((num_conflicts++)) ;;
\?\?) ((num_untracked++)) ;;
@ -50,13 +50,13 @@ if (( num_changed == 0 && num_staged == 0 && num_untracked == 0 && num_stashed =
clean=1
fi
IFS="." read -ra line <<< "${branch_line/\#\# }"
branch="${line[0]}"
IFS="^" read -ra branch_fields <<< "${branch_line/\#\# }"
branch="${branch_fields[0]}"
remote=
if [[ "$branch" == *"Initial commit on"* ]]; then
IFS=" " read -ra branch_line <<< "$branch"
branch="${branch_line[3]}"
IFS=" " read -ra fields <<< "$branch"
branch="${fields[3]}"
remote="_NO_REMOTE_TRACKING_"
elif [[ "$branch" == *"no branch"* ]]; then
tag=$( git describe --exact-match )
@ -66,17 +66,17 @@ elif [[ "$branch" == *"no branch"* ]]; then
branch="_PREHASH_$( git rev-parse --short HEAD )"
fi
else
if [[ "${#line[@]}" -eq 1 ]]; then
if [[ "${#branch_fields[@]}" -eq 1 ]]; then
remote="_NO_REMOTE_TRACKING_"
else
IFS="[,]" read -ra remote_line <<< "${line[3]}"
for rline in "${remote_line[@]}"; do
if [[ "$rline" == *ahead* ]]; then
num_ahead=${rline:6}
IFS="[,]" read -ra remote_fields <<< "${branch_fields[1]}"
for remote_field in "${remote_fields[@]}"; do
if [[ "$remote_field" == *ahead* ]]; then
num_ahead=${remote_field:6}
ahead="_AHEAD_${num_ahead}"
fi
if [[ "$rline" == *behind* ]]; then
num_behind=${rline:7}
if [[ "$remote_field" == *behind* ]]; then
num_behind=${remote_field:7}
behind="_BEHIND_${num_behind# }"
fi
done

Loading…
Cancel
Save