1
0
Fork 0
mirror of https://github.com/romkatv/powerlevel10k.git synced 2024-11-11 00:00:06 +00:00

Port #1071 to master (fatal errors emitted by untracked file check in vcs.zsh)

This commit is contained in:
Matthew Judy 2018-11-17 17:13:25 -05:00
parent 724781e896
commit 574ee6dc1c

View file

@ -8,33 +8,23 @@
set_default POWERLEVEL9K_VCS_SHOW_SUBMODULE_DIRTY false set_default POWERLEVEL9K_VCS_SHOW_SUBMODULE_DIRTY false
function +vi-git-untracked() { function +vi-git-untracked() {
[[ -z "${vcs_comm[gitdir]}" || "${vcs_comm[gitdir]}" == "." ]] && return [[ -z "${vcs_comm[gitdir]}" || "${vcs_comm[gitdir]}" == "." ]] && return
# If we are in a .git folder, do not check for untracked files.
[[ "${PWD:A}" =~ "\.git/" ]] && return
# If we are in a repos root folder, vcs_comm[gitdir] yields ".git". # get the root for the current repo or submodule
# Inside the .git dir itself (and not a subdir of it) the variable local repoTopLevel="$(command git rev-parse --show-toplevel 2> /dev/null)"
# yields ".". In any other case (either a subdirectory of .git or # dump out if we're outside a git repository (which includes being in the .git folder)
# the repo itself), the value of vcs_comm[gitdir] is the absolute [[ $? != 0 || -z $repoTopLevel ]] && return
# path to the .git directory.
# Therefore we can step up a directory, if we are inside the .git
# folder. And in any other case, use the parent directory of the
# gitdir.
local repoDir="."
# Getting the parent dir of the current dir "." is still ".", so
# is is safe to do this always.
[[ "${vcs_comm[gitdir]}" != ".git" ]] && repoDir="${vcs_comm[gitdir]:A:h}"
[[ "${vcs_comm[gitdir]}" == "." ]] && repoDir="${PWD:A:h}"
if [[ "$POWERLEVEL9K_VCS_SHOW_SUBMODULE_DIRTY" == "true" && "$(command git submodule foreach --quiet --recursive 'command git ls-files --others --exclude-standard')" != "" ]]; then local untrackedFiles=$(command git ls-files --others --exclude-standard "${repoTopLevel}")
hook_com[unstaged]+=" $(print_icon 'VCS_UNTRACKED_ICON')"
VCS_WORKDIR_HALF_DIRTY=true if [[ -z $untrackedFiles && "$POWERLEVEL9K_VCS_SHOW_SUBMODULE_DIRTY" == "true" ]]; then
elif [[ "$(command git ls-files --others --exclude-standard "${repoDir}")" != "" ]]; then untrackedFiles+=$(command git submodule foreach --quiet --recursive 'command git ls-files --others --exclude-standard')
hook_com[unstaged]+=" $(print_icon 'VCS_UNTRACKED_ICON')" fi
VCS_WORKDIR_HALF_DIRTY=true
else [[ -z $untrackedFiles ]] && return
VCS_WORKDIR_HALF_DIRTY=false
fi hook_com[unstaged]+=" $(print_icon 'VCS_UNTRACKED_ICON')"
VCS_WORKDIR_HALF_DIRTY=true
} }
function +vi-git-aheadbehind() { function +vi-git-aheadbehind() {