mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-25 20:33:08 +00:00
[git completions] Speed up branch completion
Using `git for-each-ref` both simplifies the code (no need to deal with detached heads anymore) and speeds it up. With 1600 branches, the time goes from ~48ms to ~16ms.
This commit is contained in:
parent
0b0e65a8a4
commit
f3f2d2d191
1 changed files with 5 additions and 6 deletions
|
@ -17,12 +17,11 @@ function __fish_git_recent_commits
|
|||
end
|
||||
|
||||
function __fish_git_branches
|
||||
command git branch --no-color -a $argv 2>/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\tRemote Branch'
|
||||
# This is much faster than using `git branch`,
|
||||
# and avoids having to deal with localized "detached HEAD" messages.
|
||||
command git for-each-ref --format='%(refname)' refs/heads/ refs/remotes/ \
|
||||
| string replace -r '^refs/heads/(.*)$' '$1\tLocal Branch' \
|
||||
| string replace -r '^refs/remotes/(.*)$' '$1\tRemote Branch'
|
||||
end
|
||||
|
||||
function __fish_git_tags
|
||||
|
|
Loading…
Reference in a new issue