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

Re: [PATCH 1/3] completion: put matching ctags symbol names directly into COMPREPLY

From
Jeff King <peff@peff.net>
Date
Mar 24, 2017, 00:37 UTC
Message-ID
<20170324003741.vrdhdh6ze7up5kng@sigill.intra.peff.net>
In-Reply-To
<20170323153839.24283-2-szeder.dev@gmail.com>
On Thu, Mar 23, 2017 at 04:38:37PM +0100, SZEDER Gábor wrote:
Show 11 quoted lines
> The one-liner awk script in __git_match_ctag() listing ctags symbol
> names for 'git grep <TAB>' is already smart enough to list only symbol
> names matching the current word to be completed.
> 
> Extend this helper function to accept prefix and suffix parameters to
> be prepended and appended, respectively, to each listed symbol name in
> the awk script, so its output won't require any additional processing
> or filtering in the completion script before being handed over to
> Bash.  Use the faster __gitcomp_direct() helper instead of
> __gitcomp_nl() to fill the fully processed matching symbol names into
> Bash's COMPREPLY array.

Seems like an easy win (well, neglecting the other 14 patches that let to having gitcomp_direct).

I never really noticed it as particularly slow in git.git, but faster is always better if it comes cheaply.

> Notes:
>     It's still just a simple linear search through the tags file, so there
>     are no miracles: it's still hopelessly, unusably slow e.g. in the
>     Linux repository.

I just tried "git grep foo<Tab>" in the kernel and it was pretty fast. But then I tried "git grep <Tab>". Ouch. So it seems like it's not the awk matching that's slow, but everything that comes after (and is dependent on how much output it produces).

-Peff
Previous: SZEDER GáborNext: SZEDER Gábor
Message 3 of 9 in “completion: updates to ctags symbol names”
  1. 0/3 completion: updates to ctags symbol namesSZEDER Gábor, Mar 23, 2017
  2. 1/3 completion: put matching ctags symbol names directly into COMPREPLYSZEDER Gábor, Mar 23, 2017
  3. Jeff KingMar 24, 2017
  4. 2/3 completion: extract completing ctags symbol names into helper functionSZEDER Gábor, Mar 23, 2017
  5. Jeff KingMar 24, 2017
  6. 3/3 completion: offer ctags symbol names for 'git log -S', '-G' and '-L:'SZEDER Gábor, Mar 23, 2017
  7. Jeff KingMar 24, 2017
  8. SZEDER GáborMar 30, 2017
  9. Jeff KingApr 1, 2017

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.