Fix Git indicators in submodules, close #18

This commit is contained in:
Sorin Ionescu 2012-03-07 12:03:10 -05:00
parent 8d294542d5
commit 6ac5c25e77

View File

@ -5,12 +5,36 @@
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
# Gets the path to the Git directory.
function _git-dir() {
local git_root="$(git-root)"
local git_dir_or_file="${git_root}/.git"
local git_dir
if [[ ! -d "$git_root" ]]; then
return 1
fi
if [[ -f "$git_dir_or_file" ]]; then
git_dir="${${${$(<"$git_dir_or_file")}[(fr)gitdir:*]}#gitdir: }"
else
git_dir="$git_dir_or_file"
fi
if [[ -d "$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-root)/.git"
local git_dir="$(_git-dir)"
for action_dir in \
"${git_dir}/rebase-apply" \
@ -200,7 +224,7 @@ function git-info() {
zformat -f commit_formatted "$commit_format" "c:$commit_short"
# Stashed
if [[ -f "$(git-root)/.git/refs/stash" ]]; then
if [[ -f "$(_git-dir)/refs/stash" ]]; then
stashed="$(git stash list 2>/dev/null | wc -l)"
zstyle -s ':omz:plugin:git:prompt' stashed 'stashed_format'
zformat -f stashed_formatted "$stashed_format" "S:$stashed"