Only offer local branches for deletion in git completions

This commit is contained in:
Mahmoud Al-Qudsi 2018-10-30 05:14:20 +00:00
parent 913f65cd77
commit b23bda8ed6

View File

@ -32,6 +32,11 @@ function __fish_git_branches
| string replace -r '^refs/remotes/(.*)$' '$1\tRemote Branch' | string replace -r '^refs/remotes/(.*)$' '$1\tRemote Branch'
end end
function __fish_git_local_branches
command git for-each-ref --format='%(refname)' refs/heads/ refs/remotes/ 2>/dev/null \
| string replace -rf '^refs/heads/(.*)$' '$1\tLocal Branch'
end
function __fish_git_unique_remote_branches function __fish_git_unique_remote_branches
# `git checkout` accepts remote branches without the remote part # `git checkout` accepts remote branches without the remote part
# if they are unambiguous. # if they are unambiguous.
@ -825,8 +830,8 @@ complete -f -c git -n '__fish_git_needs_command' -a bisect -d 'Find the change t
### branch ### branch
complete -f -c git -n '__fish_git_needs_command' -a branch -d 'List, create, or delete branches' complete -f -c git -n '__fish_git_needs_command' -a branch -d 'List, create, or delete branches'
complete -f -c git -n '__fish_git_using_command branch' -a '(__fish_git_branches)' complete -f -c git -n '__fish_git_using_command branch' -a '(__fish_git_branches)'
complete -f -c git -n '__fish_git_using_command branch' -s d -d 'Delete branch' complete -f -c git -n '__fish_git_using_command branch' -s d -d 'Delete branch' -xa '(__fish_git_local_branches)'
complete -f -c git -n '__fish_git_using_command branch' -s D -d 'Force deletion of branch' complete -f -c git -n '__fish_git_using_command branch' -s D -d 'Force deletion of branch' -xa '(__fish_git_local_branches)'
complete -f -c git -n '__fish_git_using_command branch' -s m -d 'Rename branch' complete -f -c git -n '__fish_git_using_command branch' -s m -d 'Rename branch'
complete -f -c git -n '__fish_git_using_command branch' -s M -d 'Force renaming branch' complete -f -c git -n '__fish_git_using_command branch' -s M -d 'Force renaming branch'
complete -f -c git -n '__fish_git_using_command branch' -s a -d 'Lists both local and remote branches' complete -f -c git -n '__fish_git_using_command branch' -s a -d 'Lists both local and remote branches'