From 0df896c3f1b691add0cba24e06d237470c116a35 Mon Sep 17 00:00:00 2001 From: Eric Nielsen Date: Mon, 27 Mar 2017 18:45:21 -0500 Subject: [PATCH] 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. --- modules/git-info/README.md | 2 +- modules/git-info/init.zsh | 12 ++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/modules/git-info/README.md b/modules/git-info/README.md index ea0cc4b..d7e230d 100644 --- a/modules/git-info/README.md +++ b/modules/git-info/README.md @@ -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. diff --git a/modules/git-info/init.zsh b/modules/git-info/init.zsh index 9043208..f41599b 100644 --- a/modules/git-info/init.zsh +++ b/modules/git-info/init.zsh @@ -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)