Squashed commit of the following:

commit e07f1d59c06094846db8ce59f65d4790b222fffa
Author: Mahmoud Al-Qudsi <mqudsi@neosmart.net>
Date:   Sun Sep 10 21:54:45 2017 -0500

    Use git branch and git branch --remote for checkout completions

commit 9e1632236be065e051e306b11082ca4e9c7a0ee1
Author: Mahmoud Al-Qudsi <mqudsi@neosmart.net>
Date:   Sun Sep 10 11:27:30 2017 -0500

    Correct classification of remote and local branches

    To prevent any breakage, no changes were made to __fish_git_branches,
    instead its output was filtered into __fish_git_remote_branches and
    __fish_git_local_branches, the two of which are now used to provide
    completions for "git checkout ..."

    Fixes #4395

Closes #4396
This commit is contained in:
Mahmoud Al-Qudsi 2017-09-14 13:42:06 -05:00
parent 856c9cf8a1
commit 864a1893bc

View file

@ -18,6 +18,14 @@ function __fish_git_recent_commits
| string replace -r '(.{73}).+' '$1…'
end
function __fish_git_local_branches
command git branch | string trim -c ' *'
end
function __fish_git_remote_branches
command git branch --remote | string trim -c ' *'
end
function __fish_git_branches
# In some cases, git can end up on no branch - e.g. with a detached head
# This will result in output like `* (no branch)` or a localized `* (HEAD detached at SHA)`
@ -362,7 +370,8 @@ complete -f -c git -n '__fish_git_using_command add' -a '(__fish_git_add_files)'
### checkout
complete -f -c git -n '__fish_git_needs_command' -a checkout -d 'Checkout and switch to a branch'
complete -k -f -c git -n '__fish_git_using_command checkout' -a '(__fish_git_branches)' --description 'Branch'
complete -k -f -c git -n '__fish_git_using_command checkout' -a '(__fish_git_local_branches)' --description 'Local Branch'
complete -k -f -c git -n '__fish_git_using_command checkout' -a '(__fish_git_remote_branches)' --description 'Remote Branch'
complete -k -f -c git -n '__fish_git_using_command checkout' -a '(__fish_git_heads)' --description 'Head'
complete -k -f -c git -n '__fish_git_using_command checkout' -a '(__fish_git_unique_remote_branches)' --description 'Remote branch'
complete -k -f -c git -n '__fish_git_using_command checkout' -a '(__fish_git_tags)' --description 'Tag'