diff options
author | Will LE <lexuandinhct@gmail.com> | 2022-05-12 16:31:00 +0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-12 11:31:00 +0200 |
commit | 4674384d1a1182484705b3fa4bd7b3267295d9cc (patch) | |
tree | 8909bee2399af53ae52cb9e6a45f9cb49e614671 /lib | |
parent | 8f56a8bdf39d7727ab0e220f0164f78c77f9c50e (diff) | |
download | zsh-4674384d1a1182484705b3fa4bd7b3267295d9cc.tar.gz zsh-4674384d1a1182484705b3fa4bd7b3267295d9cc.tar.bz2 zsh-4674384d1a1182484705b3fa4bd7b3267295d9cc.zip |
fix(lib): don't return clean with `hide-dirty=1` in `parse_git_dirty` (#10897)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/git.zsh | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/lib/git.zsh b/lib/git.zsh index be9fa7e67..390c0ad4b 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -34,26 +34,30 @@ function git_prompt_info() { # Checks if working tree is dirty function parse_git_dirty() { + if [[ "$(__git_prompt_git config --get oh-my-zsh.hide-dirty)" == "1" ]]; then + return 0 + fi + local STATUS local -a FLAGS FLAGS=('--porcelain') - if [[ "$(__git_prompt_git config --get oh-my-zsh.hide-dirty)" != "1" ]]; then - if [[ "${DISABLE_UNTRACKED_FILES_DIRTY:-}" == "true" ]]; then - FLAGS+='--untracked-files=no' - fi - case "${GIT_STATUS_IGNORE_SUBMODULES:-}" in - git) - # let git decide (this respects per-repo config in .gitmodules) - ;; - *) - # if unset: ignore dirty submodules - # other values are passed to --ignore-submodules - FLAGS+="--ignore-submodules=${GIT_STATUS_IGNORE_SUBMODULES:-dirty}" - ;; - esac - STATUS=$(__git_prompt_git status ${FLAGS} 2> /dev/null | tail -n 1) + if [[ "${DISABLE_UNTRACKED_FILES_DIRTY:-}" == "true" ]]; then + FLAGS+='--untracked-files=no' fi - if [[ -n $STATUS ]]; then + + case "${GIT_STATUS_IGNORE_SUBMODULES:-}" in + git) + # let git decide (this respects per-repo config in .gitmodules) + ;; + *) + # if unset: ignore dirty submodules + # other values are passed to --ignore-submodules + FLAGS+="--ignore-submodules=${GIT_STATUS_IGNORE_SUBMODULES:-dirty}" + ;; + esac + + STATUS=$(__git_prompt_git status ${FLAGS} 2> /dev/null | tail -n 1) + if [[ -n "$STATUS" ]]; then echo "$ZSH_THEME_GIT_PROMPT_DIRTY" else echo "$ZSH_THEME_GIT_PROMPT_CLEAN" |