From 7070af0c014c1a783a8320115bff0ff8a30b296f Mon Sep 17 00:00:00 2001 From: sandroid Date: Tue, 8 Sep 2026 21:17:44 +0200 Subject: [PATCH] fix(fish): completions fail to load with fish >= 4.8.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fish started shipping git completions in the binary with 4.2.0 and deprecated the old completion files with 4.8.0. Update forgit’s fish completion loader to support both models: * prefer `status get-file completions/git.fish` (binary-embedded completions) * fall back to `$__fish_data_dir/completions/git.fish` (completion files) Also refactors loading into a helper function to allow early returns and reduce nesting. --- completions/git-forgit.fish | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/completions/git-forgit.fish b/completions/git-forgit.fish index 40dfb75..4172619 100644 --- a/completions/git-forgit.fish +++ b/completions/git-forgit.fish @@ -20,8 +20,29 @@ function __fish_forgit_worktrees git worktree list --porcelain 2>/dev/null | string match -r '^worktree .+' | string replace 'worktree ' '' end -# Load helper functions in git completion file -not functions -q __fish_git && source $__fish_data_dir/completions/git.fish +# Load git completion functions +function __fish_forgit_load_git_completions + if functions -q __fish_git + return 0 + end + + # Fish >= 4.2.0 ships git completions in its binary + if set --local git_completions (status get-file completions/git.fish) + printf '%s\n' $git_completions | source + return 0 + end + + # Older fish versions ship completions in a file + set --local git_completions_file "$__fish_data_dir/completions/git.fish" + if test -f "$git_completions_file" + source "$git_completions_file" + return 0 + end + + return 1 +end + +__fish_forgit_load_git_completions || exit # No file completion by default complete -c git-forgit -x