Fix parsing when both ahead and behind

master
Dan Nguyen 10 years ago
parent 606388df39
commit 220d5c22b1
  1. 14
      gitstatus.sh

@ -73,15 +73,17 @@ elif [[ "$branch" == *"Initial commit on"* ]]; then
elif [[ "$branch" == *"no branch"* ]]; then elif [[ "$branch" == *"no branch"* ]]; then
branch="_PREHASH_`git rev-parse --short HEAD`" branch="_PREHASH_`git rev-parse --short HEAD`"
else else
IFS="[]" read -ra remote_line <<< "${line[3]}" IFS="[,]" read -ra remote_line <<< "${line[3]}"
if [[ "${remote_line[1]}" == *ahead* ]]; then for rline in "${remote_line[@]}"; do
num_ahead=${remote_line[1]:6} if [[ "$rline" == *ahead* ]]; then
num_ahead=${rline:6}
remote="${remote}_AHEAD_${num_ahead}" remote="${remote}_AHEAD_${num_ahead}"
fi fi
if [[ "${remote_line[1]}" == *behind* ]]; then if [[ "$rline" == *behind* ]]; then
num_behind=${remote_line[1]:7} num_behind=${rline:7}
remote="${remote}_BEHIND_${num_behind}" remote="${remote}_BEHIND_${num_behind# }"
fi fi
done
fi fi
if [[ -z "$remote" ]] ; then if [[ -z "$remote" ]] ; then

Loading…
Cancel
Save