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

Re: [PATCH/RFC] completion: complete refs in multiple steps

From
Jeff King <peff@peff.net>
Date
Jan 28, 2019, 17:27 UTC
Message-ID
<20190128172707.GA3050@sigill.intra.peff.net>
In-Reply-To
<20190128143828.GJ6702@szeder.dev>
On Mon, Jan 28, 2019 at 03:38:28PM +0100, SZEDER Gábor wrote:
Show 7 quoted lines
> > -	__gitcomp_direct "$(__git_refs "$remote" "$track" "$pfx" "$cur_" "$sfx")"
> > +	__gitcomp_direct "$(__git_refs "$remote" "$track" "$pfx" "$cur_" "$sfx" | __git_collapse_refs "$cur_")"
> >  }
> 
> In general I think it would be much better to rely more on 'git
> for-each-ref' to do the heavy lifting, extending it with new format
> specifiers/options as necessary.
FWIW, that was my first thought, too.
Show 6 quoted lines
> '%(refname:rstrip=-<N>)' already comes somewhat close to what we would
> need for full ref completion (i.e. 'refs/b<TAB>' to complete
> 'refs/bisec/bad'), we only have to figure out how many "ref path
> components" to show based on the number of path components in the
> current word to be completed.  Alas, it won't add the trailing '/' for
> "ref directories".

I think it also makes it hard to do one thing which (I think) people would want: if there is a single deep ref, complete the whole thing. E.g., given:

  $ git for-each-ref --refname='%(refname)'
  refs/heads/foo/bar
  refs/heads/foo/baz
  refs/heads/another/deep/one

we'd ideally complete "fo" to "foo/" and "ano" to "another/deep/one", rather than making the user tab through each level.

Doing that requires actually understanding that the refs are in a list, and not formatting each one independently. So I kind of wonder if it would be easier to simply have a completion mode in ref-filter.

-Peff
Previous: SZEDER GáborNext: Jeff King
Message 3 of 7 in “completion: complete refs in multiple steps”
  1. completion: complete refs in multiple stepsNguyễn Thái Ngọc Duy, Jan 28, 2019
  2. SZEDER GáborJan 28, 2019
  3. Jeff KingJan 28, 2019
  4. Jeff KingJan 28, 2019
  5. Duy NguyenJan 29, 2019
  6. Jeff KingJan 29, 2019
  7. SZEDER GáborJan 29, 2019

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.