diff --git a/utils/shgit b/utils/shgit index eb3a5b2..0ce738d 100644 --- a/utils/shgit +++ b/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)