From: Duy Nguyen <pclouds@gmail.com>
To: Jeff King <peff@peff.net>
Cc: "SZEDER Gábor" <szeder.dev@gmail.com>,
"Git Mailing List" <git@vger.kernel.org>
Subject: Re: [PATCH/RFC] completion: complete refs in multiple steps
Date: Tue, 29 Jan 2019 07:43:45 +0700 [thread overview]
Message-ID: <CACsJy8BXfY+bZKV6Jxa7-3VQyyE6hGrFS7ZAnToFwpGq_o1bpw@mail.gmail.com> (raw)
In-Reply-To: <20190128172707.GA3050@sigill.intra.peff.net>
On Tue, Jan 29, 2019 at 12:27 AM Jeff King <peff@peff.net> wrote:
>
> On Mon, Jan 28, 2019 at 03:38:28PM +0100, SZEDER Gábor wrote:
>
> > > - __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.
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.
> > '%(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.
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.
> 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.
--
Duy
next prev parent reply other threads:[~2019-01-29 0:44 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-28 9:41 [PATCH/RFC] completion: complete refs in multiple steps Nguyễn Thái Ngọc Duy
2019-01-28 14:38 ` SZEDER Gábor
2019-01-28 17:27 ` Jeff King
2019-01-28 17:27 ` Jeff King
2019-01-29 0:43 ` Duy Nguyen [this message]
2019-01-29 0:47 ` Jeff King
2019-01-29 15:36 ` SZEDER Gábor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CACsJy8BXfY+bZKV6Jxa7-3VQyyE6hGrFS7ZAnToFwpGq_o1bpw@mail.gmail.com \
--to=pclouds@gmail.com \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
--cc=szeder.dev@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).