4674384d1a1182484705b3fa4bd7b3267295d9cc
- Author
- Will LE <lexuandinhct@gmail.com>
- Committer
- GitHub <noreply@github.com>
- Date
Message
fix(lib): don't return clean with `hide-dirty=1` in `parse_git_dirty` (#10897)
Diff
1diff --git a/lib/git.zsh b/lib/git.zsh
2index be9fa7e6750b2fb44ec463bb98c0e4dddce4547f..390c0ad4b56fc1318d54c563f14a627acdfcfc6c 100644
3--- a/lib/git.zsh
4+++ b/lib/git.zsh
5@@ -34,26 +34,30 @@ function git_prompt_info() {
6
7 # Checks if working tree is dirty
8 function parse_git_dirty() {
9+ if [[ "$(__git_prompt_git config --get oh-my-zsh.hide-dirty)" == "1" ]]; then
10+ return 0
11+ fi
12+
13 local STATUS
14 local -a FLAGS
15 FLAGS=('--porcelain')
16- if [[ "$(__git_prompt_git config --get oh-my-zsh.hide-dirty)" != "1" ]]; then
17- if [[ "${DISABLE_UNTRACKED_FILES_DIRTY:-}" == "true" ]]; then
18- FLAGS+='--untracked-files=no'
19- fi
20- case "${GIT_STATUS_IGNORE_SUBMODULES:-}" in
21- git)
22- # let git decide (this respects per-repo config in .gitmodules)
23- ;;
24- *)
25- # if unset: ignore dirty submodules
26- # other values are passed to --ignore-submodules
27- FLAGS+="--ignore-submodules=${GIT_STATUS_IGNORE_SUBMODULES:-dirty}"
28- ;;
29- esac
30- STATUS=$(__git_prompt_git status ${FLAGS} 2> /dev/null | tail -n 1)
31+ if [[ "${DISABLE_UNTRACKED_FILES_DIRTY:-}" == "true" ]]; then
32+ FLAGS+='--untracked-files=no'
33 fi
34- if [[ -n $STATUS ]]; then
35+
36+ case "${GIT_STATUS_IGNORE_SUBMODULES:-}" in
37+ git)
38+ # let git decide (this respects per-repo config in .gitmodules)
39+ ;;
40+ *)
41+ # if unset: ignore dirty submodules
42+ # other values are passed to --ignore-submodules
43+ FLAGS+="--ignore-submodules=${GIT_STATUS_IGNORE_SUBMODULES:-dirty}"
44+ ;;
45+ esac
46+
47+ STATUS=$(__git_prompt_git status ${FLAGS} 2> /dev/null | tail -n 1)
48+ if [[ -n "$STATUS" ]]; then
49 echo "$ZSH_THEME_GIT_PROMPT_DIRTY"
50 else
51 echo "$ZSH_THEME_GIT_PROMPT_CLEAN"