diff --git a/gitstatus.sh b/gitstatus.sh index 8dcd49b..6d7db3c 100755 --- a/gitstatus.sh +++ b/gitstatus.sh @@ -26,15 +26,26 @@ num_conflicts=0 num_untracked=0 while IFS='' read -r line || [[ -n "$line" ]]; do status=${line:0:2} - case "$status" in - \#\#) branch_line="${line/\.\.\./^}" ;; - ?M) ((num_changed++)) ;;& - ?D) ((num_changed++)) ;;& - U?) ((num_conflicts++)) ;;& - \?\?) ((num_untracked++)) ;; - \ ?) ;; - *) ((num_staged++)) ;; - esac + while [[ -n $status ]]; do + case "$status" in + #two fixed character matches, loop finished + \#\#) branch_line="${line/\.\.\./^}"; break ;; + \?\?) ((num_untracked++)); break ;; + U?) ((num_conflicts++)); break;; + ?U) ((num_conflicts++)); break;; + DD) ((num_conflicts++)); break;; + AA) ((num_conflicts++)); break;; + #two character matches, first loop + ?M) ((num_changed++)) ;; + ?D) ((num_changed++)) ;; + ?\ ) ;; + #single character matches, second loop + U) ((num_conflicts++)) ;; + \ ) ;; + *) ((num_staged++)) ;; + esac + status=${status:0:-1} + done done <<< "$gitstatus" num_stashed=0