Merge pull request #1 from pedantic79/simple-dots-fix

Simple dots fix
master
ogr3 10 years ago
commit ed44f6bc9d
  1. 15
      gitstatus.sh

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

Loading…
Cancel
Save