mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-28 05:43:11 +00:00
completions/git: Fix git-foo commands
Broken in f5711ad5ed
, this neglected to
remove the `git-` part from the command
Fixes #9457.
This commit is contained in:
parent
f7f052ad40
commit
2da1a4ae77
2 changed files with 21 additions and 8 deletions
|
@ -2242,15 +2242,13 @@ end
|
||||||
|
|
||||||
# source git-* commands' autocompletion file if exists
|
# source git-* commands' autocompletion file if exists
|
||||||
set -f __fish_git_custom_commands_completion
|
set -f __fish_git_custom_commands_completion
|
||||||
for file in $PATHgitdash
|
for file in (path filter -xZ -- $PATHgitdash | path basename)
|
||||||
test ! -x $file
|
|
||||||
and continue
|
|
||||||
|
|
||||||
set -l subcommand (path basename $file)
|
|
||||||
# Already seen this command earlier in $PATH.
|
# Already seen this command earlier in $PATH.
|
||||||
contains -- $subcommand $__fish_git_custom_commands_completion
|
contains -- $file $__fish_git_custom_commands_completion
|
||||||
and continue
|
and continue
|
||||||
|
|
||||||
complete -c git -f -n "__fish_git_using_command $subcommand" -a "(__fish_git_complete_custom_command $subcommand)"
|
# Running `git foo` ends up running `git-foo`, so we need to ignore the `git-` here.
|
||||||
|
set -l cmd (string replace -r '^git-' '' -- $file)
|
||||||
|
complete -c git -f -n "__fish_git_using_command $cmd" -a "(__fish_git_complete_custom_command $cmd)"
|
||||||
set -a __fish_git_custom_commands_completion $subcommand
|
set -a __fish_git_custom_commands_completion $subcommand
|
||||||
end
|
end
|
||||||
|
|
|
@ -33,6 +33,19 @@ git init >/dev/null 2>&1
|
||||||
# First set up a test alias - *before loading the completions*
|
# First set up a test alias - *before loading the completions*
|
||||||
git config --local alias.re 'restore --staged'
|
git config --local alias.re 'restore --staged'
|
||||||
|
|
||||||
|
# Test custom command completions by adding a command:
|
||||||
|
|
||||||
|
set -p PATH $PWD
|
||||||
|
echo "echo foo" > git-frobnicate
|
||||||
|
chmod +x git-frobnicate
|
||||||
|
|
||||||
|
complete -c git-frobnicate -xa 'foo bar baz'
|
||||||
|
|
||||||
|
complete -C'git frobnicate '
|
||||||
|
#CHECK: bar
|
||||||
|
#CHECK: baz
|
||||||
|
#CHECK: foo
|
||||||
|
|
||||||
complete -C'git ' | grep '^add'\t
|
complete -C'git ' | grep '^add'\t
|
||||||
# (note: actual tab character in the check here)
|
# (note: actual tab character in the check here)
|
||||||
#CHECK: add Add file contents to the staging area
|
#CHECK: add Add file contents to the staging area
|
||||||
|
@ -41,9 +54,11 @@ touch foo
|
||||||
|
|
||||||
complete -C'git add '
|
complete -C'git add '
|
||||||
#CHECK: foo Untracked file
|
#CHECK: foo Untracked file
|
||||||
|
#CHECK: git-frobnicate Untracked file
|
||||||
|
|
||||||
complete -C'git add :'
|
complete -C'git add :'
|
||||||
#CHECK: :/:foo Untracked file
|
#CHECK: :/:foo Untracked file
|
||||||
|
#CHECK: :/:git-frobnicate Untracked file
|
||||||
|
|
||||||
git config alias.s status
|
git config alias.s status
|
||||||
complete 'git s --s'
|
complete 'git s --s'
|
||||||
|
@ -71,7 +86,7 @@ set -g __fish_git_prompt_show_informative_status 1
|
||||||
set -g __fish_git_prompt_showuntrackedfiles 1
|
set -g __fish_git_prompt_showuntrackedfiles 1
|
||||||
fish_git_prompt
|
fish_git_prompt
|
||||||
echo
|
echo
|
||||||
#CHECK: (newbranch|…1)
|
#CHECK: (newbranch|…2)
|
||||||
set -e __fish_git_prompt_show_informative_status
|
set -e __fish_git_prompt_show_informative_status
|
||||||
set -e __fish_git_prompt_showuntrackedfiles
|
set -e __fish_git_prompt_showuntrackedfiles
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue