Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletions functions/_tide_item_git.fish
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ function _tide_item_git
if git branch --show-current 2>/dev/null | string shorten -"$tide_git_truncation_strategy"m$tide_git_truncation_length | read -l location
git rev-parse --git-dir --is-inside-git-dir | read -fL gdir in_gdir
set location $_tide_location_color$location
test "$tide_git_hide_branch" = true && set -e location
else if test $pipestatus[1] != 0
return
else if git tag --points-at HEAD | string shorten -"$tide_git_truncation_strategy"m$tide_git_truncation_length | read location
Expand Down Expand Up @@ -46,8 +47,8 @@ function _tide_item_git
test $in_gdir = true && set -l _set_dir_opt -C $gdir/..
# Suppress errors in case we are in a bare repo or there is no upstream
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>.*))
(0|(?<dirty>.*))\n(0|(?<untracked>.*))(\n(0|(?<behind>.*))\t(0|(?<ahead>.*)))?' \
string match -qr '(0|(?<stash>.+))\n(0|(?<conflicted>.+))\n(0|(?<staged>.+))
(0|(?<dirty>.+))\n(0|(?<untracked>.+))(\n(0|(?<behind>.+))\t(0|(?<ahead>.+)))?' \
"$(git $_set_dir_opt stash list 2>/dev/null | count
string match -r ^UU $stat | count
string match -r ^[ADMR] $stat | count
Expand All @@ -61,12 +62,19 @@ function _tide_item_git
set -g tide_git_bg_color $tide_git_bg_color_unstable
end

_tide_print_item git $_tide_location_color$tide_git_icon' ' (set_color white; echo -ns $location
set_color $tide_git_color_operation; echo -ns ' '$operation ' '$step/$total_steps
set_color $tide_git_color_upstream; echo -ns ' ⇣'$behind ' ⇡'$ahead
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)
set -l git_parts (begin
echo -s $_tide_location_color$tide_git_icon
echo -s (set_color white )$location
echo -s (set_color $tide_git_color_operation )$operation
echo -s (set_color $tide_git_color_operation )$step/$total_steps
echo -s (set_color $tide_git_color_upstream )'⇣'$behind
echo -s (set_color $tide_git_color_upstream )'⇡'$ahead
echo -s (set_color $tide_git_color_stash )'*'$stash
echo -s (set_color $tide_git_color_conflicted)'~'$conflicted
echo -s (set_color $tide_git_color_staged )'+'$staged
echo -s (set_color $tide_git_color_dirty )'!'$dirty
echo -s (set_color $tide_git_color_untracked )'?'$untracked
end | string join --no-empty ' ')

_tide_print_item git $git_parts
end
1 change: 1 addition & 0 deletions functions/tide/configure/configs/classic.fish
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ tide_git_color_untracked $_tide_color_light_blue
tide_git_color_upstream $_tide_color_green
tide_git_truncation_length 24
tide_git_truncation_strategy
tide_git_hide_branch false
tide_go_bg_color 444444
tide_go_color 00ACD7
tide_java_bg_color 444444
Expand Down
1 change: 1 addition & 0 deletions functions/tide/configure/configs/classic_16color.fish
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ tide_git_color_staged bryellow
tide_git_color_stash brgreen
tide_git_color_untracked brblue
tide_git_color_upstream brgreen
tide_git_hide_branch false
tide_go_bg_color black
tide_go_color brcyan
tide_java_bg_color black
Expand Down
1 change: 1 addition & 0 deletions functions/tide/configure/configs/lean.fish
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ tide_git_color_untracked $_tide_color_light_blue
tide_git_color_upstream $_tide_color_green
tide_git_truncation_length 24
tide_git_truncation_strategy
tide_git_hide_branch false
tide_go_bg_color normal
tide_go_color 00ACD7
tide_java_bg_color normal
Expand Down
1 change: 1 addition & 0 deletions functions/tide/configure/configs/lean_16color.fish
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ tide_git_color_staged bryellow
tide_git_color_stash brgreen
tide_git_color_untracked brblue
tide_git_color_upstream brgreen
tide_git_hide_branch false
tide_go_bg_color normal
tide_go_color brcyan
tide_java_bg_color normal
Expand Down
1 change: 1 addition & 0 deletions functions/tide/configure/configs/rainbow.fish
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ tide_git_color_untracked 000000
tide_git_color_upstream 000000
tide_git_truncation_length 24
tide_git_truncation_strategy
tide_git_hide_branch false
tide_go_bg_color 00ACD7
tide_go_color 000000
tide_java_bg_color ED8B00
Expand Down
1 change: 1 addition & 0 deletions functions/tide/configure/configs/rainbow_16color.fish
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ tide_git_color_staged black
tide_git_color_stash black
tide_git_color_untracked black
tide_git_color_upstream black
tide_git_hide_branch false
tide_go_bg_color brcyan
tide_go_color black
tide_java_bg_color yellow
Expand Down
25 changes: 25 additions & 0 deletions tests/_tide_item_git.test.fish
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,31 @@ _git commit -am 'Append hello to foo'
_git checkout HEAD~
_git_item # CHECK: {{@\w*}}

# --------- hide branch ---------
_git checkout main
echo >bar
_git_item # CHECK: main ?1
set -lx tide_git_hide_branch true
_git_item # CHECK: ?1

# Mixed signs with hidden branch
_git add bar
echo modified >foo
_git_item # CHECK: +1 !1

# Verify tags still show when branch hiding enabled
_git reset --hard
_git tag v1.0
_git checkout v1.0
_git_item # CHECK: #v1.0

# Verify SHA still shows in detached HEAD
_git checkout HEAD~
_git_item # CHECK: {{@\w*}}

_git checkout main
set -lx tide_git_hide_branch false

# --- Long branches ---
_git checkout main
_git checkout -b very_long_branch_name
Expand Down