Commit Graph

49 Commits

Author SHA1 Message Date
Andy Stewart
5c636b128e Fix handling of buffer consisting only of a newline.
See #510.
2018-12-13 10:50:02 +00:00
Andy Stewart
3f642a0bb8 Add assertion for path of untracked file. 2018-11-17 17:24:48 +00:00
Andy Stewart
947737c76f Handle non-ASCII paths.
This prevents git-ls-files from escaping "unusual" characters in
pathnames.  When this happened, gitgutter would feed the escaped name
back to git-show but git-show would not recognise it.

This commit makes git-ls-files use the -z option to output pathnames
verbatim.  These pathnames also become null terminated so we have to
ensure we remove the null terminator too.

Closes #562.
2018-11-17 11:24:36 +00:00
Andy Stewart
0597380f6b Prompt user to choose hunk when overlapping.
See #556.
2018-10-18 15:39:55 +01:00
Andy Stewart
89c34f74cb Display unambiguous sign when hunks overlap.
See #556.
2018-10-18 09:45:55 +01:00
Andy Stewart
a7206c41fc Add test for files with leading dash. 2018-05-08 16:26:48 +01:00
Andy Stewart
72226496b3 Add test for encoding conversion. 2018-03-14 14:44:33 +00:00
Andy Stewart
380e7935b7 Make test flag more specific. 2018-03-08 11:47:08 +00:00
Andy Stewart
5db4a3a2a5 Make robust the replacement of temp file paths with actual paths.
The previous implementation meant the temp file paths were treated as
regular expressions, which was vulnerable to problems with backslashes
etc.

See #494.
2018-03-02 12:44:49 +00:00
Andy Stewart
e9aee00190 Switch off diff.mnemonicPrefix in tests.
Follows on c325a8b.
2018-02-22 11:04:10 +00:00
Andy Stewart
798abe53b3 Extract helper for triggering gitgutter. 2018-02-21 11:33:44 +00:00
Andy Stewart
35c92dbd50 Add test for user autocmd. 2018-02-21 11:31:48 +00:00
Andy Stewart
ef94b195ab Add tests for text objects. 2018-02-19 10:51:21 +00:00
Andy Stewart
d137753182 Handle &write option being off (e.g. vim -m FILE).
See #407.
2018-02-12 16:19:01 +00:00
Andy Stewart
5bfe5b9209 Big refactor.
- Hunk stage/undo/preview no longer saves the buffer.
- Hunk undo no longer makes locations go out of sync.
- Grep can be opted out of (grep output with ansi escapes is number one cause
  of issues).
- Replaced g:gitgutter_grep_command with g:gitgutter_grep.
- Always runs git-diff the same way instead of in two possible ways.
- Separated detection of git tracking from diffing.
- Simplified path handling.
- Removed support for xolox shell: Windows taskbar does not flash with async
  jobs.
- Removed g:gitgutter_{eager,realtime}.
- Simplified implementation generally.
2018-02-12 14:25:11 +00:00
Andy Stewart
ee481585d7 Modernise tests.
Use Vim's built-in assert_*() functions and vim-contest test runner.
2016-10-27 12:15:43 +02:00
Andy Stewart
a693c0d326 Ensure nested calls do not overwrite value of original shell.
See #379.
2016-10-19 10:00:11 +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
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
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
Andy Stewart
a30ee7f23e Handle filenames containing equals signs. 2015-10-13 13:03:14 +01:00
Andy Stewart
0e66fc915c Add test for fish shell. 2015-08-17 09:51:09 +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
7f7451813c Use an up to date vim in tests. 2015-03-10 10:18:30 +01:00
Andy Stewart
3420cbf6cb Preserve alternate buffer when processing realtime diff.
See #238.
2015-03-10 10:17:34 +01:00
Andy Stewart
a86a32c530 Test stage/revert is noop when outside a hunk. 2015-03-05 12:57:07 +01:00
Andy Stewart
1e97331587 Add test for revert subsequent nearby hunk. 2015-03-05 11:49:27 +01:00
Andy Stewart
05030aa565 Add test for staging subsequent nearby hunk. 2015-03-05 11:43:39 +01:00
Andy Stewart
65f03a6fd5 Rename function for clarity. 2015-03-05 11:36:43 +01:00
Andy Stewart
7ff7455019 Add tests for ambiguous filenames. 2014-11-19 10:03:33 +01:00
Andy Stewart
7f70d520ec Refactor the test cleanup. 2014-11-14 14:35:24 +01:00
Andy Stewart
d56d26b559 Test runner's exit code reports number of failures. 2014-11-14 14:34:30 +01:00
Andy Stewart
af1f405692 Add test for filenames with square brackets. 2014-11-14 14:23:46 +01:00
Andy Stewart
4ca2de65b7 More tests. 2014-11-14 14:14:42 +01:00
Andy Stewart
6cef76aa99 Add tests. 2014-11-14 14:06:49 +01:00
Andy Stewart
ce4e3d7c9a Add test for sign column. 2014-11-13 15:36:23 +01:00
Andy Stewart
6d91198859 Drop extension for bash script. 2014-11-13 15:32:15 +01:00
Andy Stewart
d7a1785b94 Add test for reverting hunks. 2014-11-13 15:30:48 +01:00
Andy Stewart
e5add67b03 Use clearer file extensions for test files. 2014-11-13 15:27:52 +01:00
Andy Stewart
1f2bb48be5 Add test for hunk staging. 2014-11-13 15:21:37 +01:00
Andy Stewart
dd054534a0 Allow multiple expectations per test. 2014-11-13 15:21:19 +01:00
Andy Stewart
86cde1a919 Add basic test stats. 2014-11-13 14:46:10 +01:00
Andy Stewart
d24686e1bc Extract name manipulation. 2014-11-13 14:41:26 +01:00
Andy Stewart
7d0492e509 Add section on limitations of current tests. 2014-11-13 14:30:51 +01:00
Andy Stewart
4ad4c97bb2 DRY quitting vim after each test. 2014-11-13 14:28:48 +01:00
Andy Stewart
b9f4173f7c Refactor tests to be isolated. 2014-11-13 12:32:42 +01:00
Andy Stewart
09134a5138 Add basic tests. 2014-11-12 16:52:58 +01:00