Commit Graph

83 Commits

Author SHA1 Message Date
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
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
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
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
Andy Stewart
62462a25a7 Minor refactor. 2015-08-17 09:45:31 +02:00
Manuel Johannes Messner
0ca15c8ad2 Add support for fish shell
The `&&` and the `||` operators aren't available in fish.
The equivalents are `; and` and `; or`.
Also single parentheses are used for command substitution.
The fish equivalents are `begin` and `end`.
But they aren't needed here.
2015-08-17 09:29:15 +02:00
Mathias Stearn
fe10e6474d Wipeout temporary buffer created when writing file to diff.
This avoids creating a ton of dead buffers that slow down plugins that
iterate over all buffers, such as YouCompleteMe.
2015-07-28 10:41:19 +02:00
Andy Stewart
e098491906 Preserve '[ and '] marks, and &modified, during realtime diff.
See #242.
2015-04-01 10:28:01 +02:00
Andy Stewart
3420cbf6cb Preserve alternate buffer when processing realtime diff.
See #238.
2015-03-10 10:17:34 +01:00
Andy Stewart
c6ed14c662 Finer granularity for staging/reverting hunks. 2015-03-05 11:09:18 +01:00
Eli Young
d59ac0394a Don't use --color if grep doesn't support it
Not all versions of grep support the --color flag. This checks the
output of grep --help when building the grep command and avoids using
flags that aren't compatible with the version present.

Fixes #234.
2015-03-04 11:22:39 +01:00
Andy Stewart
4a239a7602 Idiomatic execute. 2015-03-04 11:00:01 +01:00
Eli Young
0cb1e41b23 Use a temporary file for buffer for realtime diffs
`git diff` doesn't perform EOL conversion on stdin, causing it to
mistakenly flag every line as having changed when the working tree uses
a different EOL than the blobs. Writing the buffer to a temporary file
and diffing against that avoids this issue.

Fixes #232.
2015-03-04 10:55:31 +01:00
Eli Young
06240f3af3 Delete temporary blob file after use 2015-03-04 10:55:31 +01:00
Andy Stewart
1fae335a65 Force grep to produce colourless output. 2015-03-03 10:52:07 +01:00
Andy Stewart
57342e33a5 Minor refactor. 2014-11-19 10:06:17 +01:00
Chris Bandy
f73df41654 Handle files with the same name as revisions.
Before this change diffing a file with the same name as a branch would
fail because git found the name ambiguous.

See #210.
2014-11-19 10:01:09 +01:00
Andy Stewart
83309ee075 Cache the fact that a file is known to git.
This allows us to avoid checking whether a file known to git is known to
git every time we run a diff.
2014-11-17 15:41:44 +01:00
Andy Stewart
b0e9efa11c Make realtime diff use git-diff.
The only reason the realtime diff used `diff` instead of `git-diff`
previously was that I couldn't figure out how to do it in a way that
worked on Windows as well as Unix.
2014-11-11 10:14:38 +01:00
Andy Stewart
e5eb9e6ecf Fix staging of hunks coming after deleted lines.
Previously vim-gitgutter generated context-free patches and applied
those to the index.  However when staging a hunk situated after any
deleted lines, the line numbers on the patch were out by the number
of lines deleted, and without any context git would apply the patch
to the wrong part of the file in the index.

This commit ensure patches are generated with 1 line of context,
allowing git to adjust the line numbers appropriately and apply the
patch to the right location.

More lines of context would help git more to adjust line numbers; but
the more context we have the more we group together hunks we would
like to treat separately.
2014-10-16 11:50:20 +02:00
Andy Stewart
fed2dbad34 Move every function into gitgutter namespace.
This makes profiling much easier.
2014-06-26 11:09:29 +02:00