Skip to content

Commit

Permalink
completion: fill COMPREPLY directly when completing fetch refspecs
Browse files Browse the repository at this point in the history
The __git_complete_fetch_refspecs() has to iterate over __git_refs()'s
output anyway to turn the listed matching refs into refspecs, and it
knows about the prefix and suffix that has to be added to each
refspec.

Modify this function to add the prefix and suffix to each refspec
while iterating and feed the result, since it doesn't need further
processing, to the new __gitcomp_direct() helper added in the previous
commit, because it should be faster when there are a lot of refspecs
to list.

Signed-off-by: SZEDER Gábor <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
szeder authored and gitster committed Mar 23, 2017
1 parent fef56eb commit 745d655
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions contrib/completion/git-completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -536,11 +536,11 @@ __git_complete_fetch_refspecs ()
{
local i remote="$1" pfx="${2-}" cur_="${3-$cur}" sfx="${4- }"

__gitcomp_nl "$(
__gitcomp_direct "$(
for i in $(__git_refs "$remote" "" "" "$cur_") ; do
echo "$i:$i"
echo "$pfx$i:$i$sfx"
done
)" "$pfx" "$cur_" "$sfx"
)"
}

# __git_refs_remotes requires 1 argument (to pass to ls-remote)
Expand Down

0 comments on commit 745d655

Please sign in to comment.