threads / discuss / 43184

Re: Bash completion Issue?

Subject: Re: Bash completion Issue?

## tl;dr

8 messages between Nov 4, 2006 and Nov 5, 2006.

replies: 7people: 3as markdown or json

Alan Chandler· Nov 4, 2006, 12:36 UTC · lore

Bash completion Issue?

I am experiencing (and have for some time) a strange effect with bash completion on my Debian (Unstable) system. Is this a git problem, or something else?

When I type a normal command on the bash command line (say emacs) followed by the partial directory name the completion completes the directory and then adds a slash. If I type a git command (say git update-index) with the same partial directory name it completes the directory, but then adds a space. I have to backspace, manually add the slash, before continuing with the next directory or filename.

In debian, there seems to be a directory /etc/bash_completion.d with files for each of the packages, and the debian git packages have entries in there. So I assume they are derived from the completion work mentioned on this list.

What seems strange to me is that nobody else has mentioned this before now.
-- 
Alan Chandler
Shawn Pearce· Nov 4, 2006, 18:41 UTC · re: Alan Chandler · lore
Alan Chandler <alan@chandlerfamily.org.uk> wrote:
Show 6 quoted lines
> When I type a normal command on the bash command line (say emacs) followed by 
> the partial directory name the completion completes the directory and then 
> adds a slash.  If I type a git command (say git update-index) with the same 
> partial directory name it completes the directory, but then adds a space.  I 
> have to backspace, manually add the slash, before continuing with the next 
> directory or filename.

Hmm. I just tried 'git update-index' and it completed here for me as you want it to (this is with the current stock Git bash completion support).

However we do some funny things when completing into trees. E.g. the completion support for 'git ls-tree man:man<tab>' may seem a little strange but it works well for my fingers. I've never really had any problem with it.

I think the only way we differ from normal bash completion is we
sometimes don't add a space after fully completing a path name.
Usually the user has to type the space in by hand.
 
> In debian, there seems to be a directory /etc/bash_completion.d with files for 
> each of the packages, and the debian git packages have entries in there.  So 
> I assume they are derived from the completion work mentioned on this list.

What completion script is it? The one that is now shipped as part of Git has a header of the following, and resides in git.git as contrib/completion/git-completion.bash:

	#
	# bash completion support for core Git.
	#
	# Copyright (C) 2006 Shawn Pearce
	# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
	#
> What seems strange to me is that nobody else has mentioned this before now.
Maybe because you have a different completion script?
Alan Chandler· Nov 5, 2006, 00:33 UTC · re: Shawn Pearce · lore
On Saturday 04 November 2006 18:41, Shawn Pearce wrote:
> Alan Chandler <alan@chandlerfamily.org.uk> wrote:
...
Show 15 quoted lines
> > In debian, there seems to be a directory /etc/bash_completion.d with
> > files for each of the packages, and the debian git packages have entries
> > in there.  So I assume they are derived from the completion work
> > mentioned on this list.
>
> What completion script is it?  The one that is now shipped as part
> of Git has a header of the following, and resides in git.git as
> contrib/completion/git-completion.bash:
>
> 	#
> 	# bash completion support for core Git.
> 	#
> 	# Copyright (C) 2006 Shawn Pearce
> 	# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
> 	#
Well I have something like this (with git 1.4.3.3)

# 'git' bash completion and library routines used by porcelain completions. # # Copyright (c) Paolo Giarrusso, 2005 # Copyright (c) Ben Clifford, 2005 # # The master version is available at: # http://www.hawaga.org.uk/gitcompletion.git

Show 5 quoted lines
>
> > What seems strange to me is that nobody else has mentioned this before
> > now.
>
> Maybe because you have a different completion script?
Seems like it might be:-(
-- 
Alan Chandler
Shawn Pearce· Nov 5, 2006, 04:28 UTC · re: Alan Chandler · lore
Alan Chandler <alan@chandlerfamily.org.uk> wrote:
Show 9 quoted lines
> Well I have something like this (with git 1.4.3.3)
> 
> # 'git' bash completion and library routines used by porcelain completions.
> #
> # Copyright (c) Paolo Giarrusso, 2005
> # Copyright (c) Ben Clifford, 2005
> #
> # The master version is available at:
> #       http://www.hawaga.org.uk/gitcompletion.git

Maybe you can nicely ask the Debian maintainer to switch to using use the completion script that is actually shipped with git 1.4.3.3?

Alan Chandler· Nov 5, 2006, 09:30 UTC · re: Shawn Pearce · lore
On Sunday 05 November 2006 04:28, Shawn Pearce wrote:
> Maybe you can nicely ask the Debian maintainer to switch to using
> use the completion script that is actually shipped with git 1.4.3.3?
It seems to be a little bit more subtle than I first thought.

There is a separate 'git-completion' package which is not maintained by the git maintainer (Gerrit Pape) and which has not been updated since August. Its this package that contains the scripts.

I'll file a bug report against it.
-- 
Alan Chandler
Alan Chandler· Nov 5, 2006, 11:22 UTC · re: Alan Chandler · lore
On Sunday 05 November 2006 09:30, Alan Chandler wrote:
Show 11 quoted lines
> On Sunday 05 November 2006 04:28, Shawn Pearce wrote:
> > Maybe you can nicely ask the Debian maintainer to switch to using
> > use the completion script that is actually shipped with git 1.4.3.3?
>
> It seems to be a little bit more subtle than I first thought.
>
> There is a separate 'git-completion' package which is not maintained by the
> git maintainer (Gerrit Pape) and which has not been updated since August.
> Its this package that contains the scripts.
>
> I'll file a bug report against it.
 removing the git-completion package and copying the bash completion script 
from /usr/share/doc/git-core/contrib/completion to /etc/bash_completion.d 
solves the problem.  I am getting completion working fine now.
-- 
Alan Chandler
Shawn Pearce· Nov 5, 2006, 11:31 UTC · re: Alan Chandler · lore
Alan Chandler <alan@chandlerfamily.org.uk> wrote:
>  removing the git-completion package and copying the bash completion script 
> from /usr/share/doc/git-core/contrib/completion to /etc/bash_completion.d 
> solves the problem.  I am getting completion working fine now.
Good.  :-)

Let us know if there's anything you'd like to see in the bash completion... I just sent out two rounds of patches for it, but certainly still have more work to do on it.

Completion of arguments to git aliases or commands like fetch and push when --git-dir/--bare has been used is still a little buggy.

Jakub Narebski· Nov 5, 2006, 11:45 UTC · re: Shawn Pearce · lore
Shawn Pearce wrote:
Show 10 quoted lines
> Alan Chandler <alan@chandlerfamily.org.uk> wrote:
>>  removing the git-completion package and copying the bash completion script 
>> from /usr/share/doc/git-core/contrib/completion to /etc/bash_completion.d 
>> solves the problem.  I am getting completion working fine now.
> 
> Good.  :-)
> 
> Let us know if there's anything you'd like to see in the bash
> completion...  I just sent out two rounds of patches for it, but
> certainly still have more work to do on it.

I'd like to see completion for git-format-patch, git-cherry-pick and git-rebase. I tried to start doing completion for git-format-patch, but realized that I don't know bash, and bash completion enough for that.

While at it, do git-completion.bash takes into consideration that some commands doesn't accept branch which is current branch.

Otherwise, I find git-completion for bash very useful.
-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

← back to recent threads