From e3c9ce4a30eecce96bdeaedc801a9ab1f56d8092 Mon Sep 17 00:00:00 2001 From: Timothy Harding Date: Mon, 22 Dec 2025 12:29:37 -0800 Subject: [PATCH 1/5] Add tide_git_hide_branch to config presets Include new configuration variable in all of the presets. --- functions/tide/configure/configs/classic.fish | 1 + functions/tide/configure/configs/classic_16color.fish | 1 + functions/tide/configure/configs/lean.fish | 1 + functions/tide/configure/configs/lean_16color.fish | 1 + functions/tide/configure/configs/rainbow.fish | 1 + functions/tide/configure/configs/rainbow_16color.fish | 1 + 6 files changed, 6 insertions(+) diff --git a/functions/tide/configure/configs/classic.fish b/functions/tide/configure/configs/classic.fish index 2e1c2c76..3bf46ffb 100644 --- a/functions/tide/configure/configs/classic.fish +++ b/functions/tide/configure/configs/classic.fish @@ -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 diff --git a/functions/tide/configure/configs/classic_16color.fish b/functions/tide/configure/configs/classic_16color.fish index fe730c5f..cfb04869 100644 --- a/functions/tide/configure/configs/classic_16color.fish +++ b/functions/tide/configure/configs/classic_16color.fish @@ -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 diff --git a/functions/tide/configure/configs/lean.fish b/functions/tide/configure/configs/lean.fish index b9a97919..62c72fb7 100644 --- a/functions/tide/configure/configs/lean.fish +++ b/functions/tide/configure/configs/lean.fish @@ -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 diff --git a/functions/tide/configure/configs/lean_16color.fish b/functions/tide/configure/configs/lean_16color.fish index 699ce45a..671b6f5f 100644 --- a/functions/tide/configure/configs/lean_16color.fish +++ b/functions/tide/configure/configs/lean_16color.fish @@ -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 diff --git a/functions/tide/configure/configs/rainbow.fish b/functions/tide/configure/configs/rainbow.fish index 7c2ca30f..5a9039d0 100644 --- a/functions/tide/configure/configs/rainbow.fish +++ b/functions/tide/configure/configs/rainbow.fish @@ -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 diff --git a/functions/tide/configure/configs/rainbow_16color.fish b/functions/tide/configure/configs/rainbow_16color.fish index 5d206115..d0f21eef 100644 --- a/functions/tide/configure/configs/rainbow_16color.fish +++ b/functions/tide/configure/configs/rainbow_16color.fish @@ -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 From f63a4966337f0531e9accb73c52cd71f19f2f399 Mon Sep 17 00:00:00 2001 From: Timothy Harding Date: Mon, 22 Dec 2025 15:01:11 -0800 Subject: [PATCH 2/5] Only emit variables for matching groups > If a named capture group matched an empty string, > the variable will be set to the empty string (like `set var ""`). > If it did not match, > the variable will be set to nothing (like `set var`). https://fishshell.com/docs/current/cmds/string-match.html Use + instead of * to only create variables for non-empty strings. Otherwise, ``` (set_color black)$my_var ``` still emits a value when my_var is the empty string. This prepares the following commit. If we don't do this, then we end up with a bunch of extra spacing because git signs that are not present still create list items. --- functions/_tide_item_git.fish | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/_tide_item_git.fish b/functions/_tide_item_git.fish index 56e1e315..2a646af1 100644 --- a/functions/_tide_item_git.fish +++ b/functions/_tide_item_git.fish @@ -46,8 +46,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|(?.*))\n(0|(?.*))\n(0|(?.*)) -(0|(?.*))\n(0|(?.*))(\n(0|(?.*))\t(0|(?.*)))?' \ + string match -qr '(0|(?.+))\n(0|(?.+))\n(0|(?.+)) +(0|(?.+))\n(0|(?.+))(\n(0|(?.+))\t(0|(?.+)))?' \ "$(git $_set_dir_opt stash list 2>/dev/null | count string match -r ^UU $stat | count string match -r ^[ADMR] $stat | count From efde57bfca6a530faec9320ef754681e61f5635a Mon Sep 17 00:00:00 2001 From: Timothy Harding Date: Mon, 22 Dec 2025 14:38:37 -0800 Subject: [PATCH 3/5] Refactor assembly of git item parts The previous version assumes that the location will be there, so the leading space before each sign works. However, this assumption breaks when the location is omitted, resulting in extra leading space. To fix this, create each item without padding and concatenate them with spaces. --- functions/_tide_item_git.fish | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/functions/_tide_item_git.fish b/functions/_tide_item_git.fish index 2a646af1..773ef3e0 100644 --- a/functions/_tide_item_git.fish +++ b/functions/_tide_item_git.fish @@ -61,12 +61,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 From 8d0a02484a8868f3b26659fd71147241c1f20f1f Mon Sep 17 00:00:00 2001 From: Timothy Harding Date: Mon, 22 Dec 2025 14:39:42 -0800 Subject: [PATCH 4/5] Hide the branch per the configuration Delete the location variable if the branch is configured to be hidden. --- functions/_tide_item_git.fish | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/_tide_item_git.fish b/functions/_tide_item_git.fish index 773ef3e0..41d107e3 100644 --- a/functions/_tide_item_git.fish +++ b/functions/_tide_item_git.fish @@ -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 From 1b95868aeb5448411da8f2432d393b0691eaaf47 Mon Sep 17 00:00:00 2001 From: Timothy Harding Date: Mon, 22 Dec 2025 14:29:11 -0800 Subject: [PATCH 5/5] Add test cases --- tests/_tide_item_git.test.fish | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/_tide_item_git.test.fish b/tests/_tide_item_git.test.fish index d3d7f605..1ad9ec4f 100644 --- a/tests/_tide_item_git.test.fish +++ b/tests/_tide_item_git.test.fish @@ -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