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 29, 2019, 00:47 UTC
Message-ID
<20190129004752.GA4327@sigill.intra.peff.net>
In-Reply-To
<CACsJy8BXfY+bZKV6Jxa7-3VQyyE6hGrFS7ZAnToFwpGq_o1bpw@mail.gmail.com>
On Tue, Jan 29, 2019 at 07:43:45AM +0700, Duy Nguyen wrote:
Show 9 quoted lines
> > > 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.
> 
> I was more concerned whether it's a good idea to begin with. But it
> sounds like you two both think it's good otherwise would have
> objected.

Heh. I do not have any real objection, but I don't think I'd really know until I used it for a while. It may be a matter of preference, in which case we might want $GIT_COMPLETION_REF_COMPONENTS to enable/disable it (I don't have an opinion on what the default should be).

Show 17 quoted lines
> >   $ 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.
> 
> Ah ha, like github sometimes show nested submodule paths. Just one
> small modification, when doing "refs/heads/<tab>" I would just show
> 
> refs/heads/foo/
> refs/heads/another/
> 
> not refs/heads/another/deep/one to save space. But when you do
> "refs/heads/a<tab>" then you get "refs/heads/another/deep/one"
> immediately.

Yeah. It's still only one entry either way (by definition), but it's going to be much longer than all of the others. Again, I think I'd have to see it in practice to decide how much I cared either way.

Show 8 quoted lines
> > 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 for-each-mode.
> 
> That also allows more complicated logic. I think sometimes completion
> code gets it wrong (I think it's often the case with rev/path
> ambiguation, but maybe dwim stuff too). And we already have all this
> logic in C.
Yeah, agreed.
-Peff
Previous: Duy NguyenNext: SZEDER Gábor
Message 6 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.