Change git-info verbose mode implementation

so it behaves alike the non-verbose mode. For example, in the "merge"
special action context, files are being reported as both indexed and
unindexed by `git diff-index` and `git diff-files` commands in
non-verbose mode. That was not the case with the regular expressions
used in the verbose mode.
This commit is contained in:
Eric Nielsen 2017-03-27 18:45:21 -05:00 committed by Matt Hamilton
parent 449634a99e
commit 0df896c3f1
2 changed files with 5 additions and 9 deletions

View File

@ -100,5 +100,5 @@ Second, format how the above attributes are displayed in prompts:
'rprompt' '[%R]'
Last, add `$git_info[prompt]` to `$PROMPT` and `$git_info[rprompt]` to
`$RPROMPT` respectively and call `git-info` in the `prompt_name_preexec` hook
`$RPROMPT` respectively and call `git-info` in the `prompt_name_precmd` hook
function.

View File

@ -258,15 +258,11 @@ git-info() {
local untracked
# Get current status.
while IFS=$'\n' read line; do
# T (type change) is undocumented, see http://git.io/FnpMGw.
if [[ ${line} == \?\?\ * ]]; then
if [[ ${line:0:2} == '??' ]]; then
(( untracked++ ))
elif [[ ${line} == \ [DMT]\ * ]]; then
(( unindexed++ ))
elif [[ ${line} == [ACDMRT]\ \ * ]]; then
(( indexed++ ))
elif [[ ${line} == ([ACMRT][DMT]|D[MT])\ * ]]; then
(( indexed++, unindexed++ ))
else
[[ ${line:0:1} != ' ' ]] && (( indexed++ ))
[[ ${line:1:1} != ' ' ]] && (( unindexed++ ))
fi
(( dirty++ ))
done < <(${(z)status_cmd} 2>/dev/null)