Commit Graph

337 Commits

Author SHA1 Message Date
Andy Stewart
13c2943959 Add timestamps to log. Log channel traffic. 2016-04-29 10:02:15 +01:00
Andy Stewart
ae434ce89e Run tests in nvim as well as vim. 2016-04-29 09:50:57 +01:00
Andy Stewart
e607a997ce Asynchronous diffs in Vim. 2016-04-29 09:50:57 +01:00
Andy Stewart
a13478c7d6 Move comment and adjust whitespace for clarity. 2016-04-25 14:19:22 +01:00
Andy Stewart
4bed1da648 Add simple logging. 2016-04-25 13:19:50 +01:00
Andy Stewart
52d1167d7d Give up when job id is problematic. 2016-04-25 10:30:24 +01:00
Andy Stewart
5ed00d1bd3 Restore original jobstart invocation.
This reverts 16e69e6 and 103acc7 from #322.  These changes turned out to
stop the plugin working with zsh and neovim.

Fixes #324.
2016-04-22 20:39:35 +01:00
Andy Stewart
d282c33789 Fix new-line signs for untracked repo files with square brackets.
Before the plugin tries to diff a file, it checks whether git is
tracking the file.  If git isn't tracking the file, it stops there and
doesn't display any signs.  If git is tracking the file, the plugin
remembers so next time it can skip the check.

When I introduced asynchronous diffing for NeoVim (18b78361), I made a
refactoring mistake which caused the plugin on second and subsequent
runs [to always think git is tracking a file][1].

The non-realtime diffs – the ones you get when you save a buffer –
basically run `git diff FILE`.  With an untracked file git returns
nothing and exits successfully.  So although the plugin erroneously
thinks git is tracking the file, it gets an error-free, empty diff back
and so removes any and all signs.  Which means that the bug doesn't make
any difference.

However the realtime diffs write the buffer's contents to a temporary
file, and write the file as staged in the index to a temporary file,
then run `git diff FILE1 FILE2`.  To write the staged version of the
file we use `git show :FILE > TMPFILE`.

When `FILE` isn't known to git, `git show :FILE` exits with an error.
Unless, that is, [the filename contains square brackets and you're using
git v2.5.0+][2], in which case git exits successfully with empty output.

So if you're using git v2.5.0+, and you're editing an untracked file in
a repository, and the filename contains square brackets, the plugin will
think: git is tracking the file; the realtime diff is successful; the
file in the index is empty; so every line in the the working copy must
be an addition; hence a `+` sign on every line.

[1]: 18b7836168/autoload/gitgutter/diff.vim (L119-L121)
[2]: http://comments.gmane.org/gmane.comp.version-control.git/285686

Closes #325.
2016-04-22 15:04:32 +01:00
Andy Stewart
65025c9f31 Fix test to edit the correct file. 2016-04-22 11:45:40 +01:00
Andy Stewart
035ea9260c Add section on extensions to README. 2016-04-21 15:57:07 +01:00
Andy Stewart
e48824cd1d Provide a hunk text object. 2016-04-21 14:08:14 +01:00
Andy Stewart
b3db866aab Use "undo" instead of "revert" for discarding a hunk.
"Undo" is a better name than "revert" because:

- "revert" sounds like it has something to do with `git-revert` but they
  are entirely different;
- "undo" is consistent with vim's "undo": discarding changes and going
  back to the original.

Maintain backwards compatibility and add deprecation warnings.

Closes #306.
2016-04-21 11:40:27 +01:00
Greg Werbin
103acc7a23 Support both spaces and quotes in &shell
Pass the git command to `jobstart()` as a string, not a list.
`jobstart()` does some kind of internal black magic to parse strings
like `'"/usr/bin/env bash" -l'`, whereas it would be impossible to pass
in an equivalent argument using a list.
2016-04-21 10:54:41 +01:00
Greg Werbin
16e69e6571 Split the value of &shell option
Before, the value of `&shell` was being passed verbatim to `jobstart`
because no word splitting is done when the argument to `jobstart` is a
list. This would cause errors if the user's `&shell` were set to
something like `'/usr/local/bin/zsh -l'`.

This does not, however, fix another potential edge case, when the shell
command itself requires quoting (as per the example in the Neovim docs,
option E91). After doing some testing, it appears that `jobstart()` cannot
handle a quoted command, despite the recommendation in the manual (and
despite the fact that commands like `:terminal` work just fine with
double-quoted values for `&shell`). Whether this inconsistency is due to
a bug or something else, additional defensive action is probably needed.

For demonstration, try symlinking `/bin/bash` to `"./bad shell"`, and
inside Neovim setting `let &shell='"./bad shell"'. Everything works
fine, except `:call jobstart([&shell])` fails. Try various combinations
of quoting and calls to `jobstart()`, `split()`, and such: there seems
to be no way to get `jobstart()` to handle the quotes and spaces
properly without additional manipulation up-front.
2016-04-21 10:54:41 +01:00
Andy Stewart
530bf68fca Add option to disable asynchronous diffs.
Closes #318.
2016-04-21 10:29:11 +01:00
Andy Stewart
cc77f32b5b Only use "-c name=value" when git supports it.
Closes #319.
2016-04-20 12:16:06 +01:00
Andy Stewart
75eee3e407 Enable diffing against any commit.
Closes #309.
2016-04-20 11:19:34 +01:00
Andy Stewart
78d83c7056 Improve rejection of unsuitable buffers. 2016-03-29 18:17:31 +01:00
Andy Stewart
28353bd060 Add grep information to debug output. 2016-03-07 10:32:52 +00:00
Andy Stewart
3ed80d959d Whitespace. 2016-03-07 09:06:30 +00:00
Andy Stewart
f05fda98b2 Fix problem affecting neovim's omnicompletion.
Before this change, neovim's omnicompletion would always insert the
first completion option without allowing the user to choose any other.

Thanks to @lvht, @chemzqm, and @Shougo for help with this.

Closes #310, #311.
2016-03-07 09:02:56 +00:00
Andy Stewart
0af9f2a3ab Add caveats about grep's --color flag. 2016-02-21 11:22:33 +00:00
Andy Stewart
8b046bd521 Remove unnecessary code. 2016-02-09 10:13:38 +00:00
Andy Stewart
f0e2cb5b4a Avoid unnecessary diff when adding/staging/reverting hunks. 2016-02-09 10:11:41 +00:00
Andy Stewart
7ef03a7b43 More semantic function argument name. 2016-02-09 10:11:41 +00:00
Andy Stewart
68715a1903 Tweak comments. 2016-02-09 10:11:41 +00:00
Andy Stewart
be55719488 Revert 0416f20. 2016-02-09 10:11:41 +00:00
Andy Stewart
18b7836168 Neovim: run diffs asynchronously. 2016-02-09 10:11:41 +00:00
Andy Stewart
0416f209d8 Avoid unnecessary diff. 2016-02-08 14:18:52 +00:00
Dan Church
e884a0e26d Remove detection of if grep supports --color
Reverts feature introduced in commit d59ac0394a

If you know your system's grep command does not support color, please use:

    let g:gitgutter_grep_command = 'grep -e'
2016-01-28 15:01:37 +00:00
Dan Church
3131bdcbb8 Remove feature gitgutter_escape_grep
Reverts feature introduced in 5c23cadf57

In order to use an escaped grep, please replace
`g:gitgutter_escape_grep=1` with:

    let g:gitgutter_grep_command = '\grep --color=never -e'
2016-01-28 15:01:37 +00:00
Dan Church
8d229c222c Clean up exposure of the grep command
This change breaks up the determining of the user's grep command, and
the arguments it sends it.

Configuration is now:

    let g:gitgutter_grep_command = 'grep --color=never -e'

This makes it easier for users to configure now, though not quite as
flexible.
2016-01-28 15:01:37 +00:00
Dan Church
95734c6f6b Add support for option g:gitgutter_grep_command
With this change, setting `g:gitgutter_grep_command` to ' | grep --color=never -e "^@@ "'`
greatly reduces startup time.

Before this change, `diff.vim` was a major bottleneck because it calls
`grep --help`. This is mostly unnecessary except in a few cases where
the user is running a nonstandard version of grep.

`vim --startuptime start.out large_file.sql` before:

    times in msec
     clock   self+sourced   self:  sourced script
     clock   elapsed:              other lines

    000.026  000.026: --- VIM STARTING ---
    [...]
    068.463  003.645  003.500: sourcing /home/dchurch/.vim/plugin/gitgutter.vim
    [...]
    150.957  000.208  000.208: sourcing /home/dchurch/.vim/autoload/gitgutter.vim
    151.294  000.196  000.196: sourcing /home/dchurch/.vim/autoload/gitgutter/utility.vim
    165.059  012.619  012.619: sourcing /home/dchurch/.vim/autoload/gitgutter/diff.vim
    236.901  000.188  000.188: sourcing /home/dchurch/.vim/autoload/gitgutter/hunk.vim
    237.289  000.233  000.233: sourcing /home/dchurch/.vim/autoload/gitgutter/sign.vim
    [...]
    337.673  000.004: --- VIM STARTED ---

After change, and setting `g:gitgutter_grep_command = ' | grep --color=never -e "^@@ "'`:

    000.026  000.026: --- VIM STARTING ---
    [...]
    064.873  002.713  002.591: sourcing /home/dchurch/.vim/plugin/gitgutter.vim
    [...]
    134.109  000.149  000.149: sourcing /home/dchurch/.vim/autoload/gitgutter.vim
    134.337  000.147  000.147: sourcing /home/dchurch/.vim/autoload/gitgutter/utility.vim
    135.411  000.232  000.232: sourcing /home/dchurch/.vim/autoload/gitgutter/diff.vim
    187.831  000.180  000.180: sourcing /home/dchurch/.vim/autoload/gitgutter/hunk.vim
    188.223  000.175  000.175: sourcing /home/dchurch/.vim/autoload/gitgutter/sign.vim
    [...]
    285.008  000.004: --- VIM STARTED ---
2016-01-28 15:01:37 +00:00
Alexander Shabalin
4510e9b335 Use diff.autorefreshindex=0 for git diff.
This improves performance on huge repositories.

See #291 for discussion.
2016-01-19 10:07:48 +00:00
Andy Stewart
ff4f592c58 Ensure no autocommands are run when writing temporary files.
There is no evidence that autocommands were being run but this seems
like a good change to make anyway.
2016-01-15 11:12:26 +00:00
Andy Stewart
a871d857d0 Prevent buffer numbers from rapidly increasing.
Instead of creating two new temporary files every time a realtime diff is
performed, reuse the same two temporary files (per file extension).
This stops the plugin using hundreds of different temporary files.

Since the plugin now only uses a handful of temporary files we do not
need to wipeout the unlisted buffer created by vim for each index-blob's
temporary file.

In turn this means vim no longer needs hundreds of unlisted buffers, so
the next-available-buffer-number stays at sensible levels.

See #297.
2016-01-15 11:04:16 +00:00
Andy Stewart
bbeb34dca6 Add comment explaining how diffs are generated. 2016-01-15 10:27:06 +00:00
Andy Stewart
3a810a9afc Make the 'exceeded max signs' warning less intrusive.
- Only show it once per buffer.
- Redraw before echo to avoid the hit-enter prompt.

See #259.
2016-01-13 16:05:18 +00:00
Andy Stewart
f52f875fc7 Add caveat about unstaging hunks. 2015-12-16 12:18:11 +00:00
Andy Stewart
134fef6f54 Mention correct handling of line endings.
See #233 for more information.
2015-12-16 12:16:11 +00:00
Andy Stewart
fbc4e3ff02 Clarify how to get started. 2015-12-16 12:00:43 +00:00
Andy Stewart
45f6521f8a Remove fish caveat because fish is supported. 2015-12-16 11:53:01 +00:00
Andy Stewart
28aea43adf Add link to vim-signify. 2015-12-10 11:08:36 +00:00
Andy Stewart
1aed46c072 Add a note about unstaging staged changes. 2015-11-26 09:47:06 +00:00
Andy Stewart
965f8bc101 Add a note about updatetime. 2015-11-26 09:43:06 +00:00
Andy Stewart
51d9a3f2bc Clarify mappings. 2015-11-17 11:06:25 +00:00
Ilya Radchenko
bcb601acd2 Allow GitGutter* commands to be followed by other commands
See the related discussion here: https://github.com/scrooloose/syntastic/issues/1593
2015-11-07 10:05:43 -05:00
Andy Stewart
b18e23cdfa Fix broken highlight link for GitGutterChangeDeleteLine.
Thanks to @JacobLeach for pointing this out.
2015-10-21 09:43:35 +01:00
Andy Stewart
dcaa7ea4a9 Add missing section to the help's table of contents.
Thanks to @sanscore for pointing this out.
2015-10-21 09:38:02 +01:00
Andy Stewart
62cfae461f Suppress any errors from wiping out buffers.
The buffers being wiped out are temporary ones used to hold the contents
of a "real", unsaved buffer.  Ideally vim wouldn't create them at all;
and in fact it seems sometimes vim does not create them (#258).

It would be good to find why the buffers are usually there but sometimes
not.  In the meantime this change works around the problem.
2015-10-21 09:24:49 +01:00