mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-02 05:41:16 -03:00
completions/git: fix arg completion for third-party git commands, again
Commit50e595503e(completions/git: fix completions for third-party git commands, 2025-03-03) wasn't quite right, as we can see in the linked reproduction: $ fish_trace=1 complete -C 'git machete add --onto ' ----> complete -C git-machete\ add\n--onto\ The recursive completion invocation contains a spurious newline, which means that "--onto" is the command name. The newline is produced by "string escape -- add --onto" inside a command substitution. Fix this by interpreting newlines as list separators, and then joining by spaces. Fixes #11319 (cherry picked from commit360cfdb7ae)
This commit is contained in:
@@ -2571,9 +2571,9 @@ function __fish_git_complete_custom_command -a subcommand
|
||||
set -e cmd[1] # Drop "git".
|
||||
set -l subcommand_args
|
||||
if argparse -s (__fish_git_global_optspecs) -- $cmd
|
||||
set subcommand_args $argv[2..] # Drop the subcommand.
|
||||
set subcommand_args (string escape -- $argv[2..]) # Drop the subcommand.
|
||||
end
|
||||
complete -C "git-$subcommand $(string escape -- $subcommand_args) "(commandline -ct)
|
||||
complete -C "git-$subcommand $subcommand_args "(commandline -ct)
|
||||
end
|
||||
|
||||
# source git-* commands' autocompletion file if exists
|
||||
|
||||
@@ -51,6 +51,10 @@ complete -C'git frobnicate --onto '
|
||||
#CHECK: onto1
|
||||
#CHECK: onto2
|
||||
|
||||
complete -C'git frobnicate graft --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
|
||||
|
||||
Reference in New Issue
Block a user