From 4cb4c9892931419132a24c33aa1673948098ee96 Mon Sep 17 00:00:00 2001 From: Dmytro Serdiuk Date: Sun, 9 Feb 2020 12:28:36 +0200 Subject: [PATCH] Use unambiguous algorithm to complete remote branches The execution of `git branch --remotes --list` provides output like origin/HEAD -> origin/master origin/master Each seperate word will be proposed as a completion argument. So, 4 values will be suggested instead of 2: origin/HEAD - correct -> - incorrect origin/master - incorrect origin/master - correct That's why `git branch` is replaced with `git for-each-ref` command as the last one always gives a correct list of remote branches. --- completions/git-elegant.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/completions/git-elegant.bash b/completions/git-elegant.bash index aae7191..816e03a 100755 --- a/completions/git-elegant.bash +++ b/completions/git-elegant.bash @@ -26,7 +26,7 @@ _git_elegant() { accept-work|obtain-work) local opts=( ${gecops} - $(git branch --remotes --list) + $(git for-each-ref --format='%(refname:short)' refs/remotes) ) COMPREPLY=( $(compgen -W "${opts[*]}" -- ${cursor})