Fix git error when in repository with no commits

This commit is contained in:
Ilan Cosman 2021-01-24 14:44:05 -08:00
parent 8b5a815cb8
commit 12da651992

View File

@ -1,7 +1,8 @@
function _tide_item_git
# Branch or SHA
set -l location (git branch --show-current 2>/dev/null) || return
git rev-parse --git-dir --short=8 HEAD | read --local --line gitDir sha
# Repository might not have any commits, in which case this would error
git rev-parse --git-dir --short=8 HEAD 2>/dev/null | read --local --line gitDir sha
# Operation
set -l operation
@ -38,7 +39,7 @@ function _tide_item_git
# Upstream behind/ahead
git rev-list --count --left-right @{upstream}...HEAD 2>/dev/null |
read --local --delimiter=\t upstreamBehind upstreamAhead
read --local --delimiter=\t upstreamBehind upstreamAhead
test "$upstreamBehind" = 0 && set -e upstreamBehind
test "$upstreamAhead" = 0 && set -e upstreamAhead
@ -77,4 +78,4 @@ function _tide_item_git
set_color $tide_git_stash_color
printf '%s' ' *'$stash
end
end