1
0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-11-23 06:37:11 +08:00

fix(lib): don't return clean with hide-dirty=1 in parse_git_dirty (#10897)

This commit is contained in:
Will LE 2022-05-12 16:31:00 +07:00 committed by GitHub
parent 8f56a8bdf3
commit 4674384d1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -34,13 +34,17 @@ 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)
@ -51,9 +55,9 @@ function parse_git_dirty() {
FLAGS+="--ignore-submodules=${GIT_STATUS_IGNORE_SUBMODULES:-dirty}"
;;
esac
STATUS=$(__git_prompt_git status ${FLAGS} 2> /dev/null | tail -n 1)
fi
if [[ -n $STATUS ]]; then
if [[ -n "$STATUS" ]]; then
echo "$ZSH_THEME_GIT_PROMPT_DIRTY"
else
echo "$ZSH_THEME_GIT_PROMPT_CLEAN"