threads / patch / 14670

patchbash completion: Add long options for 'git describe'

Subject: [PATCH] bash completion: Add long options for 'git describe'

## tl;dr

6 messages between Jul 25, 2008 and Jul 26, 2008. Diffs are folded; open one to read it.

replies: 5people: 3as markdown or json

Thomas Rast· Jul 25, 2008, 10:02 UTC · lore
---
It seemed so tedious to type --always so I wrote this instead ;-)
 contrib/completion/git-completion.bash |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
Show changes to contrib/completion/git-completion.bash +11 −0
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 3b04934..421431c 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -665,6 +665,17 @@ _git_commit ()
 
 _git_describe ()
 {
+	__git_has_doubledash && return
+
+	local cur="${COMP_WORDS[COMP_CWORD]}"
+	case "$cur" in
+	--*)
+		__gitcomp "
+			--all --tags --contains --abbrev= --candidates=
+			--exact-match --debug --long --match --always
+			"
+		return
+	esac
 	__gitcomp "$(__git_refs)"
 }
 
-- 
1.6.0.rc0.48.g3fa0a
SZEDER Gábor· Jul 25, 2008, 13:15 UTC · re: Thomas Rast · lore

Re: [PATCH] bash completion: Add long options for 'git describe'

Hi,
On Fri, Jul 25, 2008 at 12:02:50PM +0200, Thomas Rast wrote:
> ---
Signed off by?
>  _git_describe ()
>  {
> +	__git_has_doubledash && return

This line is superfluous, because 'git describe' does not have any path arguments.

Gábor
Shawn O. Pearce· Jul 25, 2008, 16:20 UTC · re: SZEDER Gábor · lore

Re: [PATCH] bash completion: Add long options for 'git describe'

SZEDER GGGbor <szeder@ira.uka.de> wrote:
Show 9 quoted lines
> On Fri, Jul 25, 2008 at 12:02:50PM +0200, Thomas Rast wrote:
> > ---
> Signed off by?
> 
> >  _git_describe ()
> >  {
> > +	__git_has_doubledash && return
> This line is superfluous, because 'git describe' does not have any path
> arguments.

Yup. Aside from the two items described above (mising SOB line and the unnecessary double dash test) this patch looks fine.

-- 
Shawn.
Thomas Rast· Jul 26, 2008, 10:25 UTC · re: Shawn O. Pearce · lore

Re: [PATCH] bash completion: Add long options for 'git describe'

Shawn O. Pearce wrote:
Show 9 quoted lines
> SZEDER GGGbor <szeder@ira.uka.de> wrote:
> > >  _git_describe ()
> > >  {
> > > +	__git_has_doubledash && return
> > This line is superfluous, because 'git describe' does not have any path
> > arguments.
> 
> Yup.  Aside from the two items described above (mising SOB line
> and the unnecessary double dash test) this patch looks fine.

I suppose you're right. It does (empirically) attempt to parse anything following a -- as a revision argument, but similar commands like cherry-pick don't handle the -- specially either.

I'll resend a fixed version.
- Thomas
-- 
Thomas Rast
trast@student.ethz.ch
Thomas Rast· Jul 26, 2008, 10:26 UTC · re: Shawn O. Pearce · lore
Signed-off-by: Thomas Rast <trast@student.ethz.ch>
---
 contrib/completion/git-completion.bash |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
Show changes to contrib/completion/git-completion.bash +9 −0
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 3b04934..4ae8b36 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -665,6 +665,15 @@ _git_commit ()
 
 _git_describe ()
 {
+	local cur="${COMP_WORDS[COMP_CWORD]}"
+	case "$cur" in
+	--*)
+		__gitcomp "
+			--all --tags --contains --abbrev= --candidates=
+			--exact-match --debug --long --match --always
+			"
+		return
+	esac
 	__gitcomp "$(__git_refs)"
 }
 
-- 
1.6.0.rc0.50.g6a66e
Shawn O. Pearce· Jul 26, 2008, 21:52 UTC · re: Thomas Rast · lore

Re: [PATCH] bash completion: Add long options for 'git describe'

Thomas Rast <trast@student.ethz.ch> wrote:
> Signed-off-by: Thomas Rast <trast@student.ethz.ch>
Much shorter, thanks.
Acked-by: Shawn O. Pearce <spearce@spearce.org>
Show 20 quoted lines
> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> index 3b04934..4ae8b36 100755
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -665,6 +665,15 @@ _git_commit ()
>  
>  _git_describe ()
>  {
> +	local cur="${COMP_WORDS[COMP_CWORD]}"
> +	case "$cur" in
> +	--*)
> +		__gitcomp "
> +			--all --tags --contains --abbrev= --candidates=
> +			--exact-match --debug --long --match --always
> +			"
> +		return
> +	esac
>  	__gitcomp "$(__git_refs)"
>  }
>  
-- 
Shawn.

← back to recent threads