diff options
author | Dominik Ritter <dritter03@googlemail.com> | 2018-11-12 02:24:29 +0300 |
---|---|---|
committer | Dominik Ritter <dritter03@googlemail.com> | 2018-11-12 02:24:29 +0300 |
commit | fd660f4b92dd255a785a444394a00e09589b873c (patch) | |
tree | ed2462d77d19a9c669be9cae34094a90694f7946 /functions/vcs.zsh | |
parent | a6e60def4ba8b5f97e1ae4af8147a61b321d5dbf (diff) |
Fix checking for untracked files
Now the untracked files are always checked from
the root folder of the repo.
Diffstat (limited to 'functions/vcs.zsh')
-rwxr-xr-x | functions/vcs.zsh | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/functions/vcs.zsh b/functions/vcs.zsh index 4cd778a4..6c9bd055 100755 --- a/functions/vcs.zsh +++ b/functions/vcs.zsh @@ -12,10 +12,24 @@ function +vi-git-untracked() { # 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". + # Inside the .git dir itself (and not a subdir of it) the variable + # yields ".". In any other case (either a subdirectory of .git or + # the repo itself), the value of vcs_comm[gitdir] is the absolute + # 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 hook_com[unstaged]+=" $(print_icon 'VCS_UNTRACKED_ICON')" VCS_WORKDIR_HALF_DIRTY=true - elif [[ "$(command git ls-files --others --exclude-standard)" != "" ]]; then + elif [[ "$(command git ls-files --others --exclude-standard "${repoDir}")" != "" ]]; then hook_com[unstaged]+=" $(print_icon 'VCS_UNTRACKED_ICON')" VCS_WORKDIR_HALF_DIRTY=true else |