Skip to content

Commit

Permalink
Use unambiguous algorithm to complete remote branches
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
extsoft committed Feb 9, 2020
1 parent d92f18e commit 4cb4c98
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion completions/git-elegant.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down

0 comments on commit 4cb4c98

Please sign in to comment.