Git development
 help / color / mirror / Atom feed
From: "Shawn O. Pearce" <spearce@spearce.org>
To: SZEDER GGGbor <szeder@ira.uka.de>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] bash: complete full refs
Date: Thu, 27 Nov 2008 13:29:38 -0800	[thread overview]
Message-ID: <20081127212938.GB23984@spearce.org> (raw)
In-Reply-To: <1227792947-4055-1-git-send-email-szeder@ira.uka.de>

SZEDER GGGbor <szeder@ira.uka.de> wrote:
> Sometimes it's handy to complete full refs, [...]
> 
> To do that, we check whether the ref to be completed starts with
> 'refs'.
...
> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> index 0ee071b..39bf18b 100755
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -188,11 +188,22 @@ __git_tags ()
>  
>  __git_refs ()
>  {
> -	local cmd i is_hash=y dir="$(__gitdir "$1")"
> +	local i is_hash=y dir="$(__gitdir "$1")"
> +	local cur="${COMP_WORDS[COMP_CWORD]}" format refs
>  	if [ -d "$dir" ]; then
> -		if [ -e "$dir/HEAD" ]; then echo HEAD; fi
> -		git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
> -			refs/tags refs/heads refs/remotes
> +		case "$cur" in
> +		refs*)

I wonder if the pattern shouldn't be:

	refs|refs/*)

to reduce the risk of matching "refs-" and trying to do a full ref
match instead of a short ref match.

Otherwise,

Acked-by: Shawn O. Pearce <spearce@spearce.org>

-- 
Shawn.

  reply	other threads:[~2008-11-27 21:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-27 13:35 [PATCH] bash: complete full refs SZEDER Gábor
2008-11-27 21:29 ` Shawn O. Pearce [this message]
2008-11-28  0:46   ` SZEDER Gábor
2008-11-28  0:51     ` Shawn O. Pearce

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20081127212938.GB23984@spearce.org \
    --to=spearce@spearce.org \
    --cc=git@vger.kernel.org \
    --cc=szeder@ira.uka.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox