From 864a1893bcb0c59ad0983ef22a728d04f30f2c37 Mon Sep 17 00:00:00 2001 From: Mahmoud Al-Qudsi Date: Thu, 14 Sep 2017 13:42:06 -0500 Subject: [PATCH] Squashed commit of the following: commit e07f1d59c06094846db8ce59f65d4790b222fffa Author: Mahmoud Al-Qudsi 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 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 --- share/completions/git.fish | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/share/completions/git.fish b/share/completions/git.fish index fb74035df..b77143068 100644 --- a/share/completions/git.fish +++ b/share/completions/git.fish @@ -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'