git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: bash completion only provides revs, not paths

From
Uwe Kleine-König <uwe.kleine-koenig@digi.com>
Date
Apr 23, 2008, 05:56 UTC
Message-ID
<20080423055637.GA25446@digi.com>
In-Reply-To
<20080423015236.GM29771@spearce.org>
Hello Shawn,
Shawn O. Pearce wrote:
Show 22 quoted lines
> Uwe Kleine-Knig <Uwe.Kleine-Koenig@digi.com> wrote:
> > currently autocompletion in 
> > 
> > 	ukleinek@zentaur:~/gsrc/linux-2.6 git log ar<tab>
> > 
> > only yields "armltd/" (i.e. the prefix of some remote tracking branches)
> > but most of the time I want it to complete to "arch/".
> 
> Right.  It favors refs over paths.  Why?  Because I complete refs
> more than I complete paths.
>  
> > I don't understand that autocompletion stuff, but probably to fix that
> > several __git_complete_revlist should be replaced by a
> > __git_complete_revlist_or_path.  The harder part is to implement the
> > latter function.  An optimal implementation would only give back paths
> > if there is a "--" somewhere before the cursor.
> 
> Its ugly, but if we only do path name completion after a -- then
> we can just return "" as the options to bash, and it will go off
> and do the path name completion itself.  If we do path names and
> and refs at the same time, that's a disaster waiting to happen.
> We would have to do the path name completion ourselves.
I thought compgen can be used for that:
	ukleinek@zentaur:~/gsrc/linux-2.6$ compgen -f ar
	arch
> How is this?
I like it and have already applied it.
 
Show 9 quoted lines
> --8<--
> bash completion: Completely only path names after -- in options
> 
> If the user has inserted a -- before the current argument we are
> being asked to complete they are most likely trying to force Git into
> treating this argument as a path name, and not as a ref.  We should
> allow bash to complete it as a path from the local working directory.
> 
> Suggested-by: Uwe Kleine-Knig <Uwe.Kleine-Koenig@digi.com>

There is a letter missing in my name. I wonder why it's always the only non-ascii one :-)

Best regards and thanks, Uwe

-- 
Uwe Kleine-König, Software Engineer
Digi International GmbH Branch Breisach, Küferstrasse 8, 79206 Breisach, Germany
Tax: 315/5781/0242 / VAT: DE153662976 / Reg. Amtsgericht Dortmund HRB 13962
Previous: Shawn O. PearceNext: Shawn O. Pearce
Message 3 of 5 in “bash completion only provides revs, not paths”
  1. Uwe Kleine-KönigApr 22, 2008
  2. Shawn O. PearceApr 23, 2008
  3. Uwe Kleine-KönigApr 23, 2008
  4. bash completion only provides revs, not pathsShawn O. Pearce, Apr 24, 2008
  5. Uwe Kleine-KönigApr 24, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.