Only run git-status inside a work tree
This commit is contained in:
parent
dab4dcce0c
commit
e405c1de7b
13
utils/shgit
13
utils/shgit
@ -13,8 +13,11 @@ shgit()
|
||||
{
|
||||
: ${SHGIT_BEGIN:=} ${SHGIT_END:= } ${SHGIT_SEP:=:}
|
||||
|
||||
gitdir=$(git rev-parse --git-dir 2>/dev/null) && [ -n "$gitdir" ] ||
|
||||
args=$(git rev-parse --git-dir --is-inside-work-tree 2>/dev/null) ||
|
||||
return
|
||||
set -- $args
|
||||
gitdir=${1:-}
|
||||
worktree=${2:-}
|
||||
|
||||
if ! name=$(git symbolic-ref -q --short HEAD); then
|
||||
name=$(git rev-parse --short HEAD 2>/dev/null)
|
||||
@ -34,7 +37,13 @@ shgit()
|
||||
fi
|
||||
|
||||
status=
|
||||
[ -n "$(git status --porcelain)" ] && status=${SHGIT_SEP}*
|
||||
if [ "$worktree" = "true" ]; then
|
||||
if [ -n "$(git status --porcelain)" ]; then
|
||||
status=${SHGIT_SEP}*
|
||||
fi
|
||||
else
|
||||
status=${SHGIT_SEP}?
|
||||
fi
|
||||
|
||||
IFS=" " set -- $(git rev-list --left-right --count \
|
||||
@{upstream}...HEAD 2>/dev/null)
|
||||
|
Loading…
Reference in New Issue
Block a user