diff --git a/share/completions/git.fish b/share/completions/git.fish index 123e0bc30..592d358b2 100644 --- a/share/completions/git.fish +++ b/share/completions/git.fish @@ -2569,11 +2569,11 @@ complete -c git -n __fish_git_needs_command -a '(__fish_git_custom_commands)' -d function __fish_git_complete_custom_command -a subcommand set -l cmd (commandline -xpc) set -e cmd[1] # Drop "git". - set -lx subcommand_args + set -l subcommand_args if argparse -s (__fish_git_global_optspecs) -- $cmd set subcommand_args $argv[2..] # Drop the subcommand. end - complete -C "git-$subcommand \$subcommand_args "(commandline -ct) + complete -C "git-$subcommand $(string escape -- $subcommand_args) "(commandline -ct) end # source git-* commands' autocompletion file if exists diff --git a/tests/checks/git.fish b/tests/checks/git.fish index 0a4da467e..5e3d71cf3 100644 --- a/tests/checks/git.fish +++ b/tests/checks/git.fish @@ -40,12 +40,17 @@ echo "echo foo" > git-frobnicate chmod +x git-frobnicate complete -c git-frobnicate -xa 'foo bar baz' +complete -c git-frobnicate -l onto -xa 'onto1 onto2' complete -C'git frobnicate ' #CHECK: bar #CHECK: baz #CHECK: foo +complete -C'git frobnicate --onto ' +#CHECK: onto1 +#CHECK: onto2 + complete -C'git ' | grep '^add'\t # (note: actual tab character in the check here) #CHECK: add Add file contents to the staging area