From 4f46d369c4e9d7ea2f76290c6cb3a0882014eb4a Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Wed, 18 Jun 2025 23:02:54 +0200 Subject: [PATCH] completions/git: fix spurious error when no subcommand is in $PATH Systems like NixOS might not have "git-receive-pack" or any other "git-*" executable in in $PATH -- instead they patch git to use absolute paths. This is weird. But no reason for us to fail. Silence the error. Fixes #11590 --- share/completions/git.fish | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/share/completions/git.fish b/share/completions/git.fish index 4aec52ad7..781953796 100644 --- a/share/completions/git.fish +++ b/share/completions/git.fish @@ -804,7 +804,8 @@ function __fish_git_custom_commands # if any of these completion results match the name of the builtin git commands, # but it's simpler just to blacklist these names. They're unlikely to change, # and the failure mode is we accidentally complete a plumbing command. - for name in (string replace -r "^.*/git-([^/]*)" '$1' $PATH/git-*) + set -l git_subcommands $PATH/git-* + for name in (string replace -r "^.*/git-([^/]*)" '$1' $git_subcommands) switch $name case cvsserver receive-pack shell upload-archive upload-pack # skip these @@ -2612,7 +2613,8 @@ end # source git-* commands' autocompletion file if exists set -l __fish_git_custom_commands_completion -for file in (path filter -xZ $PATH/git-* | path basename) +set -l git_subcommands $PATH/git-* +for file in (path filter -xZ $git_subcommands | path basename) # Already seen this command earlier in $PATH. contains -- $file $__fish_git_custom_commands_completion and continue