This avoids shelling out twice per buffer: once to check whether git
knows about the file and once to perform the diff. Now we simply do
both in one external call.
Profiling showed external calls to git taking ~20ms. This doesn't seem
too bad but it adds up.
Profiling shows that `:sign place` and `:sign unplace` are slow despite
being native vimscript functions. This commit minimises the number of
such calls by only updating signs that have changed.
This was motivated by Vim regaining focus into a buffer with unsaved
changes, and the realtime diff being replaced with an out of date disk
diff. With this commit the realtime diff will be run again.
Use `cd` instead of `popd` because POSIX sh(1) does not have `pushd` and
also because this plugin did not pair its `pushd` with a `popd` anyway.
Use file redirection because POSIX sh(1) does not have anonymous pipes.
If the plugin slows down your Vim too much, you can have it run less
often by setting `g:gitgutter_eager = 0`.
This replaces the former options `g:gitgutter_on_bufenter` and
`g:gitgutter_on_focusgained`.
This problem was revealed when using BufExplorer:
- Open vim with two files: `$ vim a.txt b.txt`
- Type `\\` to open BufExplorer.
- Press <enter> on `b.txt`.
- Vim shows `b.txt` as expected.
- Type `\\` to open BufExplorer.
- Press <enter> on `a.txt`.
- Expected: Vim shows `a.txt`.
Actual Vim shows `a.txt`, `b.txt`, `a.txt`.
I.e. the first invocation was fine but all subsequent invocations
rapidly flicked through <new file>, <old file>, <new file>.
Previously with `gitgutter_sign_column_always = 1` the sign column would
remain after calling `GitGutterDisable`. Now the sign column is always
removed when disabling gutter.