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

Re: [PATCH] git-completion.bash: always swallow error output of for-each-ref

From
SZEDER Gábor <szeder@ira.uka.de>
Date
Feb 13, 2016, 13:53 UTC
Message-ID
<20160213145333.Horde.ZTzk8ajnzz2uB2UcNeCdPtB@webmail.informatik.kit.edu>
In-Reply-To
<alpine.DEB.2.20.1602131021170.2964@virtualbox>
Quoting Johannes Schindelin <Johannes.Schindelin@gmx.de>:
Show 17 quoted lines
> Hi Gábor,
>
> On Sat, 13 Feb 2016, SZEDER Gábor wrote:
>
>>  $ cur=m ; time __gitcomp_nl "$(__git_refs '' 1)"
>>
>>  real  0m7.641s
>>  user  0m5.888s
>>  sys   0m1.832s
>>
>> Using 'refname:strip=2' for both 'git for-each-ref' in __git_refs():
>>
>>  $ cur=m ; time __gitcomp_nl "$(__git_refs '' 1)"
>>
>>  real  0m2.848s
>>  user  0m2.308s
>>  sys   0m0.596s

I timed this one using a version that already included one from those "few more tricks", so the change from ':short' to ':strip=2' alone doesn't bring quite as much:

   $ cur=m ; time __gitcomp_nl "$(__git_refs '' 1)"
   real  0m3.645s
   user  0m3.140s
   sys   0m0.588s
Show 9 quoted lines
>> Quick'n'dirty PoC using 'refname:strip', '**' globbing and a few more
>> tricks to let 'git for-each-ref' do the filtering instead of the
>> shell loop behind __gitcomp_nl():
>>
>>  $ cur=m ; time IFS=$'\n' COMPREPLY=( $(__git_refs_PoC '' 1) )
>>
>>  real  0m0.247s
>>  user  0m0.208s
>>  sys   0m0.032s
And this one now looks like:
   $ cur=m ; time __gitcomp_direct "$(__git_refs_PoC '' 1)"
The timing results are the same.
> May I have that patch, please? ;-)

It's early days, and when I say proof of concept I mean it :) For now it only works for refs from the local repository, and only when the ref to be completed is on its own on the command line (i.e. not for 'git log master..<TAB>' or 'commit --fixup=<TAB>'), and the trailing space is hardcoded, and ... though, arguably, that already covers the majority of the cases. I only switched 'git checkout' to use this optimized version, because that was the worst offender.

So I won't send patches to the list just now, but you or anyone interested can take a peek at:

   https://github.com/szeder/git.git completion-PoC-refs-speedup
Maybe even run some numbers on Windows?
Gábor
Previous: Johannes SchindelinNext: Johannes Schindelin
Message 10 of 24 in “git-completion.bash: always swallow error output of for-each-ref”
  1. git-completion.bash: always swallow error output of for-each-refSebastian Schuberth, Feb 4, 2016
  2. Jeff KingFeb 4, 2016
  3. Johannes SchindelinFeb 4, 2016
  4. Jeff KingFeb 4, 2016
  5. Junio C HamanoFeb 4, 2016
  6. SZEDER GáborFeb 12, 2016
  7. Jeff KingFeb 12, 2016
  8. SZEDER GáborFeb 13, 2016
  9. Johannes SchindelinFeb 13, 2016
  10. SZEDER GáborFeb 13, 2016
  11. Johannes SchindelinFeb 13, 2016
  12. Jeff KingFeb 13, 2016
  13. SZEDER GáborFeb 12, 2016
  14. Jeff KingFeb 12, 2016
  15. Duy NguyenFeb 13, 2016
  16. Junio C HamanoFeb 12, 2016
  17. Jeff KingFeb 12, 2016
  18. Junio C HamanoFeb 12, 2016
  19. SZEDER GáborFeb 12, 2016
  20. Jeff KingFeb 12, 2016
  21. Junio C HamanoFeb 12, 2016
  22. Junio C HamanoFeb 23, 2016
  23. Sebastian SchuberthFeb 24, 2016
  24. Sebastian SchuberthFeb 12, 2016

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.