From 745d655dc9fd2a9a02497240b4e254059f9d54f1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?SZEDER=20G=C3=A1bor?= Date: Thu, 23 Mar 2017 16:29:23 +0100 Subject: [PATCH] completion: fill COMPREPLY directly when completing fetch refspecs MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Junio C Hamano --- contrib/completion/git-completion.bash | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 41e6589313..86c7d93b88 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -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) -- 2.11.4.GIT