mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 13:23:09 +00:00
Add repository/refspec completion to git
A few commands (fetch, pull and push at least) take a "repository" (aka
"remote") and then a "refspec" (we currently do branches here).
Fixes #2525 (seems that man is still alive)
(cherry picked from commit b32bf22616
)
This commit is contained in:
parent
4bb805b5fe
commit
901652d5c3
1 changed files with 23 additions and 7 deletions
|
@ -171,12 +171,29 @@ function __fish_git_custom_commands
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Suggest branches for the specified remote - returns 1 if no known remote is specified
|
||||||
|
function __fish_git_branch_for_remote
|
||||||
|
set -l remotes (__fish_git_remotes)
|
||||||
|
set -l remote
|
||||||
|
set -l cmd (commandline -opc)
|
||||||
|
for r in $remotes
|
||||||
|
if contains -- $r $cmd
|
||||||
|
set remote $r
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
set -q remote[1]; or return 1
|
||||||
|
__fish_git_branches | string match -- "$remote/*" | string replace -- "$remote/" ''
|
||||||
|
end
|
||||||
|
|
||||||
# general options
|
# general options
|
||||||
complete -f -c git -l help -d 'Display the manual of a git command'
|
complete -f -c git -l help -d 'Display the manual of a git command'
|
||||||
|
|
||||||
#### fetch
|
#### fetch
|
||||||
complete -f -c git -n '__fish_git_needs_command' -a fetch -d 'Download objects and refs from another repository'
|
complete -f -c git -n '__fish_git_needs_command' -a fetch -d 'Download objects and refs from another repository'
|
||||||
complete -f -c git -n '__fish_git_using_command fetch' -a '(__fish_git_remotes)' -d 'Remote'
|
# Suggest "repository", then "refspec" - this also applies to e.g. push/pull
|
||||||
|
complete -f -c git -n '__fish_git_using_command fetch; and not __fish_git_branch_for_remote' -a '(__fish_git_remotes)' -d 'Remote'
|
||||||
|
complete -f -c git -n '__fish_git_using_command fetch; and __fish_git_branch_for_remote' -a '(__fish_git_branch_for_remote)' -d 'Branch'
|
||||||
complete -f -c git -n '__fish_git_using_command fetch' -s q -l quiet -d 'Be quiet'
|
complete -f -c git -n '__fish_git_using_command fetch' -s q -l quiet -d 'Be quiet'
|
||||||
complete -f -c git -n '__fish_git_using_command fetch' -s v -l verbose -d 'Be verbose'
|
complete -f -c git -n '__fish_git_using_command fetch' -s v -l verbose -d 'Be verbose'
|
||||||
complete -f -c git -n '__fish_git_using_command fetch' -s a -l append -d 'Append ref names and object names'
|
complete -f -c git -n '__fish_git_using_command fetch' -s a -l append -d 'Append ref names and object names'
|
||||||
|
@ -393,15 +410,14 @@ complete -f -c git -n '__fish_git_using_command pull' -s k -l keep -d 'Keep down
|
||||||
complete -f -c git -n '__fish_git_using_command pull' -l no-tags -d 'Disable automatic tag following'
|
complete -f -c git -n '__fish_git_using_command pull' -l no-tags -d 'Disable automatic tag following'
|
||||||
# TODO --upload-pack
|
# TODO --upload-pack
|
||||||
complete -f -c git -n '__fish_git_using_command pull' -l progress -d 'Force progress status'
|
complete -f -c git -n '__fish_git_using_command pull' -l progress -d 'Force progress status'
|
||||||
complete -f -c git -n '__fish_git_using_command pull' -a '(git remote)' -d 'Remote alias'
|
complete -f -c git -n '__fish_git_using_command pull; and not __fish_git_branch_for_remote' -a '(__fish_git_remotes)' -d 'Remote alias'
|
||||||
complete -f -c git -n '__fish_git_using_command pull' -a '(__fish_git_branches)' -d 'Branch'
|
complete -f -c git -n '__fish_git_using_command pull; and __fish_git_branch_for_remote' -a '(__fish_git_branch_for_remote)' -d 'Branch'
|
||||||
complete -f -c git -n '__fish_git_using_command pull' -a '(__fish_git_unique_remote_branches)' -d 'Remote branch'
|
|
||||||
# TODO other options
|
# TODO other options
|
||||||
|
|
||||||
### push
|
### push
|
||||||
complete -f -c git -n '__fish_git_needs_command' -a push -d 'Update remote refs along with associated objects'
|
complete -f -c git -n '__fish_git_needs_command' -a push -d 'Update remote refs along with associated objects'
|
||||||
complete -f -c git -n '__fish_git_using_command push' -a '(git remote)' -d 'Remote alias'
|
complete -f -c git -n '__fish_git_using_command push; and not __fish_git_branch_for_remote' -a '(__fish_git_remotes)' -d 'Remote alias'
|
||||||
complete -f -c git -n '__fish_git_using_command push' -a '(__fish_git_branches)' -d 'Branch'
|
complete -f -c git -n '__fish_git_using_command push; and __fish_git_branch_for_remote' -a '(__fish_git_branches)' -d 'Branch'
|
||||||
complete -f -c git -n '__fish_git_using_command push' -l all -d 'Push all refs under refs/heads/'
|
complete -f -c git -n '__fish_git_using_command push' -l all -d 'Push all refs under refs/heads/'
|
||||||
complete -f -c git -n '__fish_git_using_command push' -l prune -d "Remove remote branches that don't have a local counterpart"
|
complete -f -c git -n '__fish_git_using_command push' -l prune -d "Remove remote branches that don't have a local counterpart"
|
||||||
complete -f -c git -n '__fish_git_using_command push' -l mirror -d 'Push all refs under refs/'
|
complete -f -c git -n '__fish_git_using_command push' -l mirror -d 'Push all refs under refs/'
|
||||||
|
@ -418,7 +434,7 @@ complete -f -c git -n '__fish_git_using_command push' -l progress -d 'Force prog
|
||||||
|
|
||||||
### rebase
|
### rebase
|
||||||
complete -f -c git -n '__fish_git_needs_command' -a rebase -d 'Forward-port local commits to the updated upstream head'
|
complete -f -c git -n '__fish_git_needs_command' -a rebase -d 'Forward-port local commits to the updated upstream head'
|
||||||
complete -f -c git -n '__fish_git_using_command rebase' -a '(git remote)' -d 'Remote alias'
|
complete -f -c git -n '__fish_git_using_command rebase' -a '(__fish_git_remotes)' -d 'Remote alias'
|
||||||
complete -f -c git -n '__fish_git_using_command rebase' -a '(__fish_git_branches)' -d 'Branch'
|
complete -f -c git -n '__fish_git_using_command rebase' -a '(__fish_git_branches)' -d 'Branch'
|
||||||
complete -f -c git -n '__fish_git_using_command rebase' -l continue -d 'Restart the rebasing process'
|
complete -f -c git -n '__fish_git_using_command rebase' -l continue -d 'Restart the rebasing process'
|
||||||
complete -f -c git -n '__fish_git_using_command rebase' -l abort -d 'Abort the rebase operation'
|
complete -f -c git -n '__fish_git_using_command rebase' -l abort -d 'Abort the rebase operation'
|
||||||
|
|
Loading…
Reference in a new issue