[git completions] Make branches work on git 2.7.0 again

This used the "--format" option, which was only added in git 2.13.0.
This commit is contained in:
Fabian Homborg 2018-03-06 22:02:43 +01:00
parent 3792fb086a
commit 754b52bb26

View file

@ -19,12 +19,11 @@ function __fish_git_recent_commits
end
function __fish_git_branches
command git branch --no-color -a --format='%(refname)' $argv ^/dev/null \
# Filter out anything that's not in "refs/" notation -
# this happens mostly with a detached head ("(HEAD detached at SOMESHA)", localized).
| string replace -rf '^refs/' '' \
command git branch --no-color -a $argv ^/dev/null \
# Filter out detached heads and such ("(HEAD detached at SOMESHA)", localized).
| string match -v '\* (*)' | string match -r -v ' -> ' | string trim -c "* " \
# We assume anything that's not remote is a local branch.
| string replace -r '^(?!remotes/)[^/]+/(.*)' '$1\tLocal Branch' \
| string replace -r '^(?!remotes/)(.*)' '$1\tLocal Branch' \
| string replace -r "^remotes/(.*)" '$1\tRemote Branch'
end