Minor performance improvement for git item

This commit is contained in:
Ilan Cosman 2021-11-08 16:14:48 -08:00
parent 133f043923
commit 267187e0de

View File

@ -1,14 +1,15 @@
function _tide_item_git function _tide_item_git
if git branch --show-current 2>/dev/null | string replace -r "(.{$tide_git_truncation_length}).+" '$1…' | read -l location if git branch --show-current 2>/dev/null | string replace -r "(.{$tide_git_truncation_length}).+" '$1…' | read -l location
set location $_tide_location_color$location
git rev-parse --git-dir --is-inside-git-dir | read -f --line git_dir inside_git_dir git rev-parse --git-dir --is-inside-git-dir | read -f --line git_dir inside_git_dir
set location $_tide_location_color$location
else if test $pipestatus[1] != 0 else if test $pipestatus[1] != 0
return return
else else if git tag --points-at HEAD | string replace -r "(.{$tide_git_truncation_length}).+" '$1…' | read location
# --quiet = don't error if there are no commits git rev-parse --git-dir --is-inside-git-dir | read -f --line git_dir inside_git_dir
set location '#'$_tide_location_color$location
else # --quiet = don't error if there are no commits
git rev-parse --git-dir --is-inside-git-dir --quiet --short HEAD | read -f --line git_dir inside_git_dir sha git rev-parse --git-dir --is-inside-git-dir --quiet --short HEAD | read -f --line git_dir inside_git_dir sha
git tag --points-at HEAD | string replace -r "(.{$tide_git_truncation_length}).+" '$1…' | read location && set location @$_tide_location_color$sha
set location '#'$_tide_location_color$location || set location @$_tide_location_color$sha
end end
# Operation # Operation