2021-01-17 22:22:02 +03:00
|
|
|
function _tide_item_git
|
2023-03-26 19:40:37 +03:00
|
|
|
if git branch --show-current 2>/dev/null | string shorten -"$tide_git_truncation_strategy"m$tide_git_truncation_length | read -l location
|
2022-06-14 18:52:27 +03:00
|
|
|
git rev-parse --git-dir --is-inside-git-dir | read -fL gdir in_gdir
|
2021-11-09 03:14:48 +03:00
|
|
|
set location $_tide_location_color$location
|
2021-10-31 20:53:43 +03:00
|
|
|
else if test $pipestatus[1] != 0
|
|
|
|
return
|
2023-03-26 19:40:37 +03:00
|
|
|
else if git tag --points-at HEAD | string shorten -"$tide_git_truncation_strategy"m$tide_git_truncation_length | read location
|
2022-06-14 18:52:27 +03:00
|
|
|
git rev-parse --git-dir --is-inside-git-dir | read -fL gdir in_gdir
|
2021-11-09 03:14:48 +03:00
|
|
|
set location '#'$_tide_location_color$location
|
2021-11-14 02:42:24 +03:00
|
|
|
else
|
2022-06-14 18:52:27 +03:00
|
|
|
git rev-parse --git-dir --is-inside-git-dir --short HEAD | read -fL gdir in_gdir location
|
2022-01-17 04:00:40 +03:00
|
|
|
set location @$_tide_location_color$location
|
2021-05-12 18:33:35 +03:00
|
|
|
end
|
2021-01-17 02:15:33 +03:00
|
|
|
|
2021-01-17 04:17:18 +03:00
|
|
|
# Operation
|
2022-06-14 18:52:27 +03:00
|
|
|
if test -d $gdir/rebase-merge
|
2023-07-30 01:33:30 +03:00
|
|
|
# Turn ANY into ALL, via double negation
|
|
|
|
if not path is -v $gdir/rebase-merge/{msgnum,end}
|
|
|
|
read -f step <$gdir/rebase-merge/msgnum
|
|
|
|
read -f total_steps <$gdir/rebase-merge/end
|
|
|
|
end
|
2022-06-14 18:52:27 +03:00
|
|
|
test -f $gdir/rebase-merge/interactive && set -f operation rebase-i || set -f operation rebase-m
|
|
|
|
else if test -d $gdir/rebase-apply
|
2023-07-30 01:33:30 +03:00
|
|
|
if not path is -v $gdir/rebase-apply/{next,last}
|
|
|
|
read -f step <$gdir/rebase-apply/next
|
|
|
|
read -f total_steps <$gdir/rebase-apply/last
|
|
|
|
end
|
2022-06-14 18:52:27 +03:00
|
|
|
if test -f $gdir/rebase-apply/rebasing
|
2021-09-23 18:35:10 +03:00
|
|
|
set -f operation rebase
|
2022-06-14 18:52:27 +03:00
|
|
|
else if test -f $gdir/rebase-apply/applying
|
2021-09-23 18:35:10 +03:00
|
|
|
set -f operation am
|
2021-01-17 02:15:33 +03:00
|
|
|
else
|
2021-09-23 18:35:10 +03:00
|
|
|
set -f operation am/rebase
|
2021-01-17 02:15:33 +03:00
|
|
|
end
|
2022-06-14 18:52:27 +03:00
|
|
|
else if test -f $gdir/MERGE_HEAD
|
2021-09-23 18:35:10 +03:00
|
|
|
set -f operation merge
|
2022-06-14 18:52:27 +03:00
|
|
|
else if test -f $gdir/CHERRY_PICK_HEAD
|
2021-09-23 18:35:10 +03:00
|
|
|
set -f operation cherry-pick
|
2022-06-14 18:52:27 +03:00
|
|
|
else if test -f $gdir/REVERT_HEAD
|
2021-09-23 18:35:10 +03:00
|
|
|
set -f operation revert
|
2022-06-14 18:52:27 +03:00
|
|
|
else if test -f $gdir/BISECT_LOG
|
2021-09-23 18:35:10 +03:00
|
|
|
set -f operation bisect
|
2021-01-17 02:15:33 +03:00
|
|
|
end
|
2021-01-16 20:49:48 +03:00
|
|
|
|
2021-10-09 19:59:22 +03:00
|
|
|
# Git status/stash + Upstream behind/ahead
|
2022-06-14 18:52:27 +03:00
|
|
|
test $in_gdir = true && set -l _set_dir_opt -C $gdir/..
|
2021-10-09 19:59:22 +03:00
|
|
|
# Suppress errors in case we are in a bare repo or there is no upstream
|
2023-03-29 03:16:06 +03:00
|
|
|
set -l stat (git $_set_dir_opt --no-optional-locks status --porcelain 2>/dev/null)
|
|
|
|
string match -qr '(0|(?<stash>.*))\n(0|(?<conflicted>.*))\n(0|(?<staged>.*))
|
2021-10-09 19:59:22 +03:00
|
|
|
(0|(?<dirty>.*))\n(0|(?<untracked>.*))(\n(0|(?<behind>.*))\t(0|(?<ahead>.*)))?' \
|
2022-04-22 17:59:11 +03:00
|
|
|
"$(git $_set_dir_opt stash list 2>/dev/null | count
|
2022-06-14 18:52:27 +03:00
|
|
|
string match -r ^UU $stat | count
|
|
|
|
string match -r ^[ADMR]. $stat | count
|
|
|
|
string match -r ^.[ADMR] $stat | count
|
|
|
|
string match -r '^\?\?' $stat | count
|
2021-10-09 19:59:22 +03:00
|
|
|
git rev-list --count --left-right @{upstream}...HEAD 2>/dev/null)"
|
2021-01-17 03:50:50 +03:00
|
|
|
|
2021-10-03 22:07:00 +03:00
|
|
|
if test -n "$operation$conflicted"
|
2021-06-27 20:47:11 +03:00
|
|
|
set -g tide_git_bg_color $tide_git_bg_color_urgent
|
2021-10-03 22:07:00 +03:00
|
|
|
else if test -n "$staged$dirty$untracked"
|
2021-06-27 20:47:11 +03:00
|
|
|
set -g tide_git_bg_color $tide_git_bg_color_unstable
|
|
|
|
end
|
|
|
|
|
2021-10-31 21:16:17 +03:00
|
|
|
_tide_print_item git $_tide_location_color$tide_git_icon' ' (set_color white; echo -ns $location
|
2021-09-23 18:35:10 +03:00
|
|
|
set_color $tide_git_color_operation; echo -ns ' '$operation ' '$step/$total_steps
|
2021-09-24 03:47:59 +03:00
|
|
|
set_color $tide_git_color_upstream; echo -ns ' ⇣'$behind ' ⇡'$ahead
|
2021-09-08 20:54:31 +03:00
|
|
|
set_color $tide_git_color_stash; echo -ns ' *'$stash
|
|
|
|
set_color $tide_git_color_conflicted; echo -ns ' ~'$conflicted
|
|
|
|
set_color $tide_git_color_staged; echo -ns ' +'$staged
|
|
|
|
set_color $tide_git_color_dirty; echo -ns ' !'$dirty
|
|
|
|
set_color $tide_git_color_untracked; echo -ns ' ?'$untracked)
|
2021-01-25 01:44:05 +03:00
|
|
|
end
|