Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git bash auto complete slow on windows 7 x64

I have two machines where git bash auto complete is agonizingly slow. When I hit tab, it can take 8 to 10 seconds for the filename to be completed. This only seems to happen when the auto complete is part of a git command. Auto complete for cd works fine. The actual execution of the git command runs fine.

I am using git version 1.8.3-preview20130601

$ git count-objects -vH
count: 9
size: 10.23 KiB
in-pack: 2488
packs: 1
size-pack: 18.68 MiB
prune-packable: 0
garbage: 0
size-garbage: 0 bytes

What could be causing this? Is there any possible fix?

EDIT: I updated to Git (version 1.8.4-preview20130916) and the problem still persists. I did notice that when running the bash shell in ConEmu the command displayed at the bottom during the long pause is uniq.exe. It seems that the call to that executable is what is chewing up the time.

EDIT: Updating to git version 1.9.0.msysgit.0 has alleviated much of the problem. The delay is now only 1 to 2 seconds. Other commands like cd are still almost instant (< 0.5s). I also do not see uniq.exe running anymore, just sh.exe.

like image 826
TwistedTech Avatar asked Nov 12 '13 17:11

TwistedTech


People also ask

What is bash auto completion?

Bash completion is a bash function that allows you to auto complete commands or arguments by typing partially commands or arguments, then pressing the [Tab] key. This will help you when writing the bash command in terminal.

Why is git auto completion useful?

It can really save you a lot of typing. If there is more than one possibility, then it will let you know that it needs more information and you can type a little bit more of the word and try again. Git auto-completion is a separate script, and it's included inside the Git source code repository on GitHub.


2 Answers

I was still having an issue with slow autocomplete for git commands only, using version 1.9.5. Autocompleting at the root level could take 8 seconds, though it was faster at lower levels with fewer files.

I finally fixed the issue with information found here: https://github.com/msysgit/msysgit/wiki/Diagnosing-why-Git-is-so-slow

By setting git config core.fscache true for my repository, the autocomplete runs faster for many commands, like add and diff, though not all, such as rm. I hope that helps.

like image 30
David Merriman Avatar answered Sep 28 '22 06:09

David Merriman


Git 2.13 (Q2 2017) should improve Git bash completion, because the refs completion for large number of refs has been sped up, partly by giving up disambiguating ambiguous refs and partly by eliminating most of the shell processing between 'git for-each-ref' and 'ls-remote' and Bash's completion facility.

See commit 227307a, commit 745d655, commit fef56eb, commit 400a755, commit 824388d, commit e8cb023, commit e896369, commit b2b6811, commit 3ad8ea7, commit aed3881, commit aa0644f, commit 2ea328a, commit 15b4a16 (23 Mar 2017), and commit c977eef (03 Feb 2017) by SZEDER Gábor (szeder).
(Merged by Junio C Hamano -- gitster -- in commit bf65060, 30 Mar 2017)

For example:

completion: speed up branch and tag completion

Modify __git_heads() and __git_tags() and the few callsites they have, so we can let 'git for-each-ref' do all the hard work and these functions' output won't need any further processing or filtering before being handed over to Bash, resulting in faster branch and tag completion. These are some of the same tricks used in the previous commits to speed up refs completion, namely:

  • Extend both functions to accept prefix, current word and suffix positional parameters, all optional and all empty by default to keep the parameterless behavior unaltered.

  • Specify appropriate globbing patterns to 'git for-each-ref' to list only branches or tags matching the given current word parameter.

  • Modify the 'git for-each-ref --format=<...>' to include the given prefix and suffix.

  • Adjust all callsites to specify the proper prefix, current word and suffix parameters, and to fill COMPREPLY using __gitcomp_direct().


Note: the performance of filename completion improves with Git 2.18 (Q2 2018): see "Git bash-completion with filename support?"

like image 117
VonC Avatar answered Sep 28 '22 06:09

VonC