Re: [PATCH] completion: avoid ls-remote in certain scenarios
- From
SZEDER Gábor <szeder@ira.uka.de>
- Date
- May 29, 2013, 07:44 UTC
- Message-ID
- <20130529074408.GA7955@goldbirke>
- In-Reply-To
- <1369797648-2921-1-git-send-email-felipe.contreras@gmail.com>
On Tue, May 28, 2013 at 10:20:48PM -0500, Felipe Contreras wrote:
Show 30 quoted lines
> It's _very_ slow in many cases, and there's really no point in fetching
> *everything* from the remote just for completion. In many cases it might
> be faster for the user to type the whole thing.
>
> If the user manually specifies 'refs/*', then the full ls-remote
> completion is triggered.
>
> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
> ---
> contrib/completion/git-completion.bash | 10 ++--------
> 1 file changed, 2 insertions(+), 8 deletions(-)
>
> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> index 1c35eef..2ce4f7d 100644
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -427,14 +427,8 @@ __git_refs ()
> done
> ;;
> *)
> - git ls-remote "$dir" HEAD ORIG_HEAD 'refs/tags/*' 'refs/heads/*' 'refs/remotes/*' 2>/dev/null | \
> - while read -r hash i; do
> - case "$i" in
> - *^{}) ;;
> - refs/*) echo "${i#refs/*/}" ;;
> - *) echo "$i" ;;
> - esac
> - done
> + echo "HEAD"
> + git for-each-ref --format="%(refname:short)" -- "refs/remotes/$dir/" | sed -e "s#^$dir/##"This case statement is only executed when $dir is not a git directory, so what ensures that the cwd is in a git repo or work tree when executing this brach of the case statement? What about 'git --git-dir=/path/to/repo' invocations or when $GIT_DIR is specified?
Gábor