From 9baa0e175577c2a445792eb32ee2aa4423bac3aa Mon Sep 17 00:00:00 2001 From: Michael Allen Date: Sun, 2 Aug 2015 17:33:17 +0100 Subject: Fixed missing staged and unstaged modifications case --- git-base.sh | 4 ++-- test-status.sh | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/git-base.sh b/git-base.sh index 917e46b..2aa7462 100755 --- a/git-base.sh +++ b/git-base.sh @@ -220,7 +220,7 @@ staged_status() { local suffix=${3:-""} local staged_string="" - local filesModified="$(echo "$gitStatus" | grep -p "M[ACDR ] " | wc -l | grep -oEi '[1-9][0-9]*')" + local filesModified="$(echo "$gitStatus" | grep -p "M[ACDRM ] " | wc -l | grep -oEi '[1-9][0-9]*')" local filesAdded="$(echo "$gitStatus" | grep -p "A[MCDR ] " | wc -l | grep -oEi '[1-9][0-9]*')" local filesDeleted="$(echo "$gitStatus" | grep -p "D[AMCR ] " | wc -l | grep -oEi '[1-9][0-9]*')" local filesRenamed="$(echo "$gitStatus" | grep -p "R[AMCD ] " | wc -l | grep -oEi '[1-9][0-9]*')" @@ -272,7 +272,7 @@ unstaged_status() { local suffix=${3:-""} local unstaged_string="" - local filesModified="$(echo "$gitStatus" | grep -p "[ACDR ]M " | wc -l | grep -oEi '[1-9][0-9]*')" + local filesModified="$(echo "$gitStatus" | grep -p "[ACDRM ]M " | wc -l | grep -oEi '[1-9][0-9]*')" local filesDeleted="$(echo "$gitStatus" | grep -p "[AMCR ]D " | wc -l | grep -oEi '[1-9][0-9]*')" if [ -n "$filesDeleted" ]; then diff --git a/test-status.sh b/test-status.sh index a831151..2977361 100755 --- a/test-status.sh +++ b/test-status.sh @@ -11,6 +11,7 @@ A staged-added D staged-deleted C staged-copied R staged-renamed +MM staged-and-unstaged-modified UD deleted-them-conflicted AU added-us-conflicted UU modified-both-conflicted @@ -20,10 +21,10 @@ UU modified-both-conflicted prefix="_" suffix="-" - assertEquals "line:${LINENO}" "1_D-1_M-"\ + assertEquals "line:${LINENO}" "1_D-2_M-"\ "$(unstaged_status "$status" "$prefix" "$suffix")" - assertEquals "line:${LINENO}" "1_A-1_D-1_M-1_R-1_C-"\ + assertEquals "line:${LINENO}" "1_A-1_D-2_M-1_R-1_C-"\ "$(staged_status "$status" "$prefix" "$suffix")" assertEquals "line:${LINENO}" "1_U-1_T-1_B-"\ -- cgit v1.2.3