mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-10-23 04:30:24 +02:00
32662: vcs_info git: Fix stagedstr for empty repos
In empty repositories, HEAD is an unresolvable symbolic ref. Start computing stagedstr/unstagedstr in that case; for the former, use a different method than the non-empty-repository case.
This commit is contained in:
parent
f5ad1ccbd6
commit
b85b09b78b
2 changed files with 15 additions and 4 deletions
|
@ -128,16 +128,22 @@ elif zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" "check-for-staged-change
|
|||
querystaged=1
|
||||
fi
|
||||
if (( querystaged || queryunstaged )) && \
|
||||
[[ "$(${vcs_comm[cmd]} rev-parse --is-inside-git-dir 2> /dev/null)" != 'true' ]] && \
|
||||
${vcs_comm[cmd]} rev-parse --quiet --verify HEAD &> /dev/null ; then
|
||||
[[ "$(${vcs_comm[cmd]} rev-parse --is-inside-work-tree 2> /dev/null)" == 'true' ]] ; then
|
||||
# Default: off - these are potentially expensive on big repositories
|
||||
if (( queryunstaged )) ; then
|
||||
${vcs_comm[cmd]} diff --no-ext-diff --ignore-submodules --quiet --exit-code ||
|
||||
gitunstaged=1
|
||||
fi
|
||||
if (( querystaged )) ; then
|
||||
${vcs_comm[cmd]} diff-index --cached --quiet --ignore-submodules HEAD 2> /dev/null
|
||||
(( $? && $? != 128 )) && gitstaged=1
|
||||
if ${vcs_comm[cmd]} rev-parse --quiet --verify HEAD &> /dev/null ; then
|
||||
${vcs_comm[cmd]} diff-index --cached --quiet --ignore-submodules HEAD 2> /dev/null
|
||||
(( $? && $? != 128 )) && gitstaged=1
|
||||
else
|
||||
# empty repository (no commits yet)
|
||||
# 4b825dc642cb6eb9a060e54bf8d69288fbee4904 is the git empty tree.
|
||||
${vcs_comm[cmd]} diff-index --cached --quiet --ignore-submodules 4b825dc642cb6eb9a060e54bf8d69288fbee4904 2>/dev/null
|
||||
(( $? && $? != 128 )) && gitstaged=1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue