diff --git a/modules/git/functions/git-dir b/modules/git/functions/git-dir new file mode 100644 index 00000000..a52e6c2e --- /dev/null +++ b/modules/git/functions/git-dir @@ -0,0 +1,16 @@ +# +# Gets the path to the Git directory. +# +# Authors: +# Sorin Ionescu +# + +local git_dir="${$(git rev-parse --git-dir):A}" + +if [[ -n "$git_dir" ]]; then + print "$git_dir" + return 0 +fi + +return 1 + diff --git a/modules/git/functions/git-info b/modules/git/functions/git-info index 26b38fde..87f3a86b 100644 --- a/modules/git/functions/git-info +++ b/modules/git/functions/git-info @@ -67,24 +67,12 @@ # Load dependencies. omodload 'trap' -# Gets the path to the Git directory. -function _git-dir { - local git_dir="${$(git rev-parse --git-dir):A}" - - if [[ -n "$git_dir" ]]; then - print "$git_dir" - return 0 - fi - - return 1 -} - # Gets the Git special action (am, merge, rebase, etc.). # Borrowed from vcs_info and edited. function _git-action { local action='' local action_dir - local git_dir="$(_git-dir)" + local git_dir="$(git-dir)" for action_dir in \ "${git_dir}/rebase-apply" \ @@ -279,7 +267,7 @@ function git-info { fi # Format stashed. - if [[ -f "$(_git-dir)/refs/stash" ]]; then + if [[ -f "$(git-dir)/refs/stash" ]]; then stashed="$(git stash list 2> /dev/null | wc -l)" zstyle -s ':omz:module:git' stashed 'stashed_format' zformat -f stashed_formatted "$stashed_format" "S:$stashed"