224 Commits
v3.3 ... v3.4

Author SHA1 Message Date
Tim Pope
2a53d79248 fugitive.vim 3.4
* Use jobs for all Git execution.  Faster and less prone to user error.
* Stream :Git! to the preview window.
* Make :Git grep behave like other :Git commands, not :Ggrep.
* Silence output and open quickfix list on :Ggrep -q.
* Support :Ggrep outside repository with --no-index.
* Expand ##, $ENVVAR, and ~/path in arguments to :Git.
* Expand "%" and other special sequences during tab completion.
* Improve tab completion for :Git push.
* Disable -- More -- prompt on :Git push, fetch, and --no-pager.
* Provide FugitiveObject/FugitiveStageBlob/FugitivePager events.
* Simplify :Gdiffsplit "smart" split direction.
* Support jump to commit in :Git log --graph.
* Use local not upstream branch name for :GBrowse default.
* Better support for ssh config in :GBrowse.
* Replace older deprecation warnings with error messages.
* Assorted public API enhancements.
* Require Git 1.8.5 or newer.
* Require Vim 7.3 or newer.  Full functionality requires Vim 8.1.
* Directly echo :Git output for trivial commands like "add" on Vim 7.
* Fix E1208 when loading plugin on Vim 8.2.3141.
2021-09-02 13:03:27 -04:00
Tim Pope
2e395fa450 Provide FugitiveDidChange() 2021-09-01 19:20:46 -04:00
Tim Pope
46404ad937 Enforce 'autowrite' in all subcommands 2021-09-01 19:20:46 -04:00
Tim Pope
2f3cd4715d Remove :Gcgrep
This was a hedge in case I decided to go all in with symmetry with
:Gclog.  I have decided to to.
2021-09-01 19:20:46 -04:00
Tim Pope
90ef74fddd Fix :Git difftool on Vim 7 2021-09-01 18:40:29 -04:00
Tim Pope
ebc7ddac6d Fix :Ggrep on Vim 7 2021-09-01 18:36:52 -04:00
Tim Pope
8bdbbf88a4 Change :Gstatus to error stub 2021-09-01 17:39:28 -04:00
Tim Pope
ef8e771b25 Document ++curwin 2021-09-01 09:57:26 -04:00
Tim Pope
a7d224bfd1 Support :Git ++curwin blame % 2021-09-01 09:57:26 -04:00
Tim Pope
46a4387054 Change :0,1Git blame to split by default
The 0,0 solution had issues so let's go ahead and rip the band-aid off
now.  The repeated get(a:options, 'curwin') && a:line2 < 0 ternary is
really gross but I estimate it to be the lowest impact change that moves
us in the right direction.
2021-09-01 09:42:30 -04:00
Tim Pope
3d30a2a6d3 Expand ~~ as cwd
This is a hedge to allow a way to force a cwd path even if the
handling of "./" ever changes.
2021-09-01 08:48:41 -04:00
Tim Pope
254cc8e81d Tab complete !bufnr 2021-09-01 07:54:47 -04:00
Tim Pope
5b0a4af8fc Improve fallback go-to-file in temp buffers 2021-08-31 23:19:31 -04:00
Tim Pope
b96e1a3967 Update :Gpush FAQ entry to mention :Git! 2021-08-31 17:51:46 -04:00
Tim Pope
a5d997fe8b Pre-expand argument when completing Git objects 2021-08-31 17:51:46 -04:00
Tim Pope
8920453f5d Return full ref name on FugitiveHead(-1) 2021-08-31 17:51:46 -04:00
Tim Pope
2016ce1db4 Fix check for maps disabled by dictionary
Resolves: https://github.com/tpope/vim-fugitive/issues/1822
2021-08-31 16:33:21 -04:00
Tim Pope
2b37219021 Fix check for -addr=other on nvim
I arrived at 0.4.0 by blaming the documentation, but apparently the
feature didn't land until later.
2021-08-31 16:33:21 -04:00
Tim Pope
9ace6c6aca Expand :GMove and :GRename arguments 2021-08-31 14:59:50 -04:00
Tim Pope
4efb697fce Document :Ggrep -q 2021-08-31 14:59:50 -04:00
Tim Pope
97505a4c37 Expand :(literal)./ arguments to use cwd 2021-08-31 14:59:50 -04:00
Tim Pope
3e032f295f Clean up job dictionary entry after nvim job completes 2021-08-31 14:59:50 -04:00
Tim Pope
0d8dc0f31c Add stdin support to FugitiveExecute() 2021-08-31 13:49:39 -04:00
Tim Pope
cabcbc263a Further tweak to direct :Git blame count handling
I want to reclaim :0,1Git blame for :split, since we can use that even
with -addr=other, so go ahead and add 0,6 as our backwards compatible
way to force :edit.
2021-08-31 12:27:29 -04:00
Tim Pope
404f8a2d34 Replace #ReloadStatus() with #DidChange() 2021-08-31 12:02:17 -04:00
Tim Pope
30bf224453 Fix direct blame maps in short files
Patch 8.1.560 is the gift that keeps on giving.  Let's work around this
for now by bolting on a new behavior to the previously unused :0,0Git
blame.  Long term, we probably want to come up with a different
interface.
2021-08-31 12:01:21 -04:00
Tim Pope
328501d4f0 Make "q" error maps consistent 2021-08-31 12:01:21 -04:00
Tim Pope
b64c426fd2 Try :Git for default dispatch in status buffer
The downside of this approach is it has a different interaction model
than the quickfix list.  The upside is that it's more or less what I
actually want.  To those finding this wondering why it's now
synchronous, you can make it asynchronous by pressing CTRL-D.
2021-08-31 06:59:37 -04:00
Tim Pope
d6e1a57b58 Accept a dictionary in fugitive#RemoteHttpHeaders() 2021-08-31 06:59:37 -04:00
Tim Pope
6b546f37d0 Better HTTP redirect detection
These HTTP headers may have other :GBrowse applications, so if we're
parsing them, we may as well hang onto them.
2021-08-30 09:25:52 -04:00
Tim Pope
dfd7be2294 Fix error on :GBrowse remote/branch@remote 2021-08-29 16:32:22 -04:00
Tim Pope
10b44345b0 Extend :Gdiffsplit zero argument positioning to ">" arguments
And change the jump to file map to use it, eliminating the behavior
change there (at least for now).

Resolves: https://github.com/tpope/vim-fugitive/issues/1821
2021-08-29 12:15:51 -04:00
Tim Pope
acfcb068ed Don't append another filename when expanding ">commit:file"
This opens up the possibility of using ">" to navigate to a renamed
version of a file, for example.
2021-08-29 12:14:55 -04:00
Tim Pope
6f0ff0ed00 Favor ssh:// URL over scp style when possible
This is much easier to deal with on other end, so if a :GBrowse provider
doesn't care about relative scp paths, allow them to ditch the scp
parsing entirely.
2021-08-29 12:13:14 -04:00
Tim Pope
a6be4a301c Limit size based :Gdiffsplit orientation to no argument variant
I don't think anybody liked this except for me.  This brings :Gdiffsplit
one step closer to :diffsplit.  The no argument version will probably be
removed eventually as well, but let's take it one step at a time.
2021-08-29 03:53:21 -04:00
Tim Pope
c9aaf78541 Force :leftabove for :Gdiffsplit! with argument
After receiving feedback, I have decided that the forced direction is
what most people expect, so let's limit our :diffsplit matching to the
non-bang variant, for now at least.
2021-08-29 03:53:21 -04:00
Tim Pope
d523feebe9 Respect 'splitbelow' on :Gdiffsplit with argument
When calling :Gdiffsplit with no argument, we always end up with the
work tree version as half of the diff, and it is helpful to position
that consistently.  I generalized this to a consistent older versus
newer ordering when given an argument, but I don't think that has proven
very useful in practice.

This also introduces a minor behavior change where calling the bang
variant in the initial commit now loads an empty version of the buffer,
rather than falling back to the work tree.
2021-08-28 11:47:13 -04:00
Tim Pope
4603d77424 Provide :Gdiffsplit ++novertical
Maybe one day we can kill :Ghdiffsplit.
2021-08-28 11:47:13 -04:00
Tim Pope
6b7892dc7b Fix edge case in s:Map() short circuiting
When called with multiple modes, don't bail after the first disabled
mode.

This also restructures in a way to allow for transition to :exe s:Map(),
which will provide the correct line number on :verbose map <whatever>.
2021-08-28 11:47:13 -04:00
Tim Pope
cdf60a312c Provide User FugitivePager autocommand event 2021-08-28 08:14:50 -04:00
Tim Pope
385c0fb4ee Use <cfile> not <cword> for temp file "." map
Also, skip over that "+" that marks work-tree branches in :Git branch
output.
2021-08-28 08:14:50 -04:00
Tim Pope
4f747add5e Support jump to commit in :Git log --graph 2021-08-27 11:28:45 -04:00
Tim Pope
18fd27e2cc Provide slightly less bad "." map in temp buffers
Doing this right isn't on the horizon, so hack up something that's
better than nothing.
2021-08-27 11:28:45 -04:00
Tim Pope
fa5892dcac Map "(" and ")" in blame buffers
For symmetry with the other buffers.  A nice enhancement would be to
jump between distinct commits but this is good enough for now.
2021-08-27 11:28:45 -04:00
Tim Pope
46a2f58e1d Provide utility function to expire cached config
This is primarily for troubleshooting, but might also be handy for
users of includeIf.
2021-08-27 11:28:45 -04:00
Tim Pope
126363be5a Tweak Vim 7 more prompt behavior 2021-08-26 13:35:55 -04:00
Tim Pope
4ff2c8ce30 Disable -- More -- prompt on push/fetch
These commands have slow, potentially verbose output, especially in the
case where pushing triggers a real time deploy.
2021-08-26 10:11:25 -04:00
Tim Pope
5aa8a3489e Directly echo :Git output for a few trivial commands on Vim 7
If this works out, we can change the status buffer to directly call
:Git rather than routing through FugitiveExecute().
2021-08-26 10:11:25 -04:00
Tim Pope
ad8c1c80cc Work around hostile ftplugin/man.vim
References: https://github.com/neovim/neovim/issues/15487
2021-08-26 09:12:20 -04:00
Tim Pope
7e21d414a8 Trigger FugitiveChanged after writing stage buffer
I deliberately omitted this event when adding FugitiveChanged, because I
figured it made sense for consumers to instead tap into BufWritePost to
see which file changed exactly.  This would enable, say, vim-gitgutter,
to only refresh signs for the file that actually changed, rather
than for every file in the repository.  In practice, however,
vim-gitgutter doesn't even bother with "in the repository", let alone
the exact file, opting instead to refresh every loaded buffer.  I give
up.

Resolves: https://github.com/tpope/vim-fugitive/issues/1819
2021-08-25 22:56:12 -04:00
Tim Pope
09d3551627 Don't show "Bare" status for worktrees attached to bare repos
I tried to make this foolproof and once again someone has invented a
bigger fool.
2021-08-25 07:38:41 -04:00
Tim Pope
74b0960f5b Add deprecation warning to FugitivePrepare()
I am eager to reclaim this verb, so let's deprecate sooner rather than
later.
2021-08-25 05:00:04 -04:00
Tim Pope
de02a4ba84 Change deprecated Git wrappers to error stubs 2021-08-25 05:00:04 -04:00
Tim Pope
93174147cd Provide FugitiveGitVersion()
I should have made fugitive#GitVersion() official a long time ago.
Better late than never.
2021-08-25 05:00:04 -04:00
Tim Pope
b06ad2a839 Provide FugitiveExecute() 2021-08-25 05:00:04 -04:00
Tim Pope
61e1e94785 Make FugitiveConfig(callback) asynchronous 2021-08-25 05:00:04 -04:00
Tim Pope
b07632a616 Fix :Git merge
Resolves: https://github.com/tpope/vim-fugitive/issues/1817
2021-08-25 05:00:01 -04:00
Tim Pope
e91d17ddc2 Adjust User events for fugitive:// buffers 2021-08-24 19:16:04 -04:00
Tim Pope
6dd18b5c98 Support :Git ++curwin
The special case on :0Git is so weird that I am starting to think about
an exit strategy.
2021-08-24 19:16:04 -04:00
Tim Pope
7c1f2ed185 Move config --list parsing into Execute callback
This is 80% of the way to an asynchronous config retrieval.  Do we
really want to make a 10 millisecond Git call asynchronous?  Hard to
say.
2021-08-24 14:43:10 -04:00
Tim Pope
8cdb51622f Focus quickfix list after :Ggrep! -q
This just feels right.  If we're not jumping to a file, we probably want
to scroll the list.
2021-08-23 03:00:44 -04:00
Tim Pope
5c39cde202 Don't match git grep "BUG:" lines as filename
Found this playing around with git grep --no-index /absolute/path.
2021-08-23 03:00:44 -04:00
Tim Pope
f7de229fe7 Default :Git grep to pager, not quickfix
And bring back the column default when we do use the quickfix, why not?
2021-08-23 01:51:50 -04:00
Tim Pope
1a4552da8d Support :Ggrep --no-index/--no-cached 2021-08-23 01:51:50 -04:00
Tim Pope
22fff8213e Better :Ggrep quickfix patterns 2021-08-23 01:49:55 -04:00
Tim Pope
0bd41bd387 Expand ~ and $VAR in :Git arguments 2021-08-23 01:26:52 -04:00
Tim Pope
490e03c3ad Fix line number inclusion in :Ggrep 2021-08-22 23:34:10 -04:00
Tim Pope
06b0bf147f Handle jump to file in :Git -p grep without line number 2021-08-22 23:16:42 -04:00
Tim Pope
bbfbfaa0a2 Fix command preparation bug 2021-08-22 23:16:42 -04:00
Tim Pope
a41810fa86 Better support for --no-literal-pathspecs
When given an argument list including --no-literal-pathspecs and a
buffer number, convert the buffer number to an argument by prepending
":(top,literal)" to the filename rather than "./".  This allows
operating on file names that include special characters like "*" and
"?".
2021-08-22 22:40:36 -04:00
Tim Pope
89ab2d95cd Drop Vim requirement to 7.3
The code base still supports 7.3 (7.2.061 to be precise) so no harm in
dropping this for one final release.
2021-08-22 22:09:48 -04:00
Tim Pope
557ef84c6d Improve public API argument order flexibility 2021-08-22 22:09:48 -04:00
Tim Pope
e7d2e87690 Do what I mean for :Git -c alias.foo=blame foo 2021-08-22 02:48:58 -04:00
Tim Pope
5d1a276b45 Distinguish between uses of Git dir
We use the Git dir for a few purposes:

* Direct filesystem access.
* Passing to Git as --git-dir=.
* Embedding in fugitive:// URLs.
* Referring to the repository without otherwise using it.

As a start to teasing these apart, introduce s:GitDir() to handle the
first 2 cases, s:DirUrlPrefix() for the 3rd case, and keep using s:Dir()
as a generic reference.
2021-08-22 02:48:49 -04:00
Tim Pope
7c0a7727c1 Allow FugitiveRemoteUrl(name, ':noresolve') 2021-08-22 02:47:00 -04:00
Tim Pope
baffbd6291 Fix config functions with config dictionary as first argument 2021-08-22 02:44:38 -04:00
Tim Pope
e7be4e4af9 Fix false positive "unknown Git error" 2021-08-22 00:21:33 -04:00
Tim Pope
c7a93960c7 Fix FugitiveRemoteUrl() 2021-08-22 00:21:33 -04:00
Tim Pope
b5a3775b64 Remove unused keys from :GBrowse options
I was hoping to one day introduce a new, backwards incompatible API
here, but adoption has gotten widespread enough that I think we're stuck
with it.  So let's go ahead and clean up some cruft that I've verified
is not in use in any known plugin.  A couple of plugins do use
repo.rev_parse(), but only inside conditionals should never be
triggered.
2021-08-21 21:26:45 -04:00
Tim Pope
1bd77bec75 Include remote_name in :GBrowse options
Uses for this are limited, but it does allow for retrieving the raw URL
before resolution, or for getting other properties from the remote's Git
config.

Also, allow FugitiveRemoteUrl(browse_opts) to directly retrieve the URL.
2021-08-21 21:26:45 -04:00
Tim Pope
39ff394b4e Rearrange fugitive#ResolveRemote()
This came out of a refactor to return the various URL components
separately.  I'm not ready to merge that, but this change feels like
enough of an improvement to merge for its own sake.
2021-08-21 21:26:45 -04:00
Tim Pope
57eeed2545 Add alternatives to :GBrowse ++remote=
In the same way Vim requires custom commands to start with an uppercase
letter, I'm starting to think we should self-impose the same constraint
on custom ++options.  Also, let's throw "Git" in there, just to allow
this to be truly unique if necessary.

This also allows a special remote argument of ".git" to refer to the
local repository.  A possible use of this would be a local gitweb
handler.
2021-08-21 21:26:45 -04:00
Tim Pope
4e6b7b6ce9 Don't accept 0 to refer to alternate buffer
This allows a sensible interpretation when using 0 as a stand-in for
"false".  You can use bufnr('#') if you need the old behavior.
2021-08-21 19:55:43 -04:00
Tim Pope
199dbb1164 Fix duplicate help tag
Pretty sure basically nobody used the old usage so this is fine.
2021-08-20 19:43:52 -04:00
Tim Pope
46358f87e7 Fix U in status window
Must have fat fingered this at the last second.  I mean, I forgot the
<C-U>, but I most definitely did not forget the colon.
2021-08-20 18:50:11 -04:00
Tim Pope
7e53b2aef9 Update documentation for :Git 2021-08-20 17:23:28 -04:00
Tim Pope
66a070ab14 Use :Git --no-pager in Vim 7 to directly echo output
At long last we will have a way to directly invoke :Git from inside
various status maps without subjecting Vim 7 users to a press enter
prompt.
2021-08-20 17:23:28 -04:00
Tim Pope
98039f3349 Move FugitivePath() away from documented functions
This function has weird semantics and does not rise to the level of its
peers.
2021-08-20 13:09:20 -04:00
Tim Pope
05a443cd6e Add unofficial raw argument list support to fugitive#Execute()
Hedging our bets for the future.
2021-08-20 13:09:20 -04:00
Tim Pope
2c6bd3bd2d Improve tab completion for :Git push
References: https://github.com/tpope/vim-fugitive/issues/1813
2021-08-20 11:50:05 -04:00
Tim Pope
aae36024b8 Introduce FugitiveShellCommand() to replace FugitivePrepare()
We've moved on from the shell as the one true way, so let's demote the
one true preparation function.
2021-08-20 10:24:57 -04:00
Tim Pope
3125b07645 Fix :Ggrep argument parsing off-by-one error 2021-08-20 10:24:57 -04:00
Tim Pope
f674916597 Eliminate speck of repetition around :Git --no-pager
It's not the repetition that bothers me so much as the fact these two
things belong side by side.
2021-08-20 10:24:57 -04:00
Tim Pope
b70c10f2bd Disable 'more' on :Git --no-pager 2021-08-20 08:59:51 -04:00
Tim Pope
9cf20dbff5 Don't set $COLUMNS on legacy :! implementation
It's unnecessary and offensive to the eye.
2021-08-20 08:59:51 -04:00
Tim Pope
2f51a93e89 Fix pseudo-job execution on Vim 7
Closes https://github.com/tpope/vim-fugitive/issues/1815
2021-08-20 08:59:51 -04:00
Tim Pope
fd24cb2acd Add -z to :Ggrep quickfix opening flags
I mean, it's not like we can do anything else with it.
2021-08-20 00:47:49 -04:00
Tim Pope
86a45846fc Use :Ggrep -q to eschew output in favor of quickfix window
The q works on 2 levels!
2021-08-20 00:31:41 -04:00
Tim Pope
e716ebdda9 Avoid more possibilities for :Ggrep more prompt
I think this could only happen with a screen one line high, but let's
avoid tempting fate
2021-08-19 22:25:07 -04:00
Tim Pope
771d1e3711 Avoid line echo during jump to file in :Git -p grep 2021-08-19 19:36:22 -04:00
Tim Pope
01e843c21d Avoid :Ggrep interrupt leaving behind result without file 2021-08-19 19:35:33 -04:00
Tim Pope
0cbc28ba33 Avoid -- More -- prompt during :Ggrep
Resolves: https://github.com/tpope/vim-fugitive/issues/1814
2021-08-19 16:36:44 -04:00
Tim Pope
81f293852e Stream to preview window on :Git! command 2021-08-19 13:51:20 -04:00
Tim Pope
e93d45e4ce Fix constructing Git shell commands 2021-08-19 13:50:42 -04:00
Tim Pope
eafb44a720 Use jobs for :Git --paginate 2021-08-19 13:31:37 -04:00
Tim Pope
952a49f688 Tweak check for Git in PATH
First attempt was overthinking it.
2021-08-19 13:23:20 -04:00
Tim Pope
9ba2680ad5 Add special case error for failure to find Git in PATH 2021-08-19 12:13:03 -04:00
Tim Pope
98bd8428b5 Add optional callback to FugitiveConfig()
Obvious next step is to make this asynchronous, but let's settle for
getting the API in place for now.
2021-08-19 11:09:47 -04:00
Tim Pope
9ab7ac303a Accept Git dir as first argument to FugitiveRemoteUrl() 2021-08-18 13:11:57 -04:00
Tim Pope
286bf9096d Use jobs for :Ggrep 2021-08-17 22:49:39 -04:00
Tim Pope
6c18adaf98 Use jobs for quickfix commands 2021-08-17 21:47:24 -04:00
Tim Pope
9a2299038b Standardize on 'git_dir' as dictionary key
We've been moving this way for a while, but progress is slow, so let's
help it along a bit.
2021-08-17 21:47:24 -04:00
Tim Pope
809efd3f62 Fix :Gedit .git with nonstandard .git dir 2021-08-17 20:43:53 -04:00
Tim Pope
9216210b86 Pass --git-dir= alongside -C for nontrivial cases
References: https://github.com/tpope/vim-fugitive/issues/1796
2021-08-17 20:29:09 -04:00
Tim Pope
64133cae30 Avoid unnecessary -C when querying Git config
Let's keep this low level operation away from any wonkiness caused by a
missing or bad core.worktree.
2021-08-17 20:29:09 -04:00
Tim Pope
9b31f4bee5 Include cwd in fugitive#Execute() result
I guess we should allow for the future possibility the working directory
can be specified.
2021-08-17 19:59:04 -04:00
Tim Pope
40542f1dd1 Include --no-literal-pathspecs in FugitiveResult().flags
This allows for passing the result to helpers like
fugitive#ShellCommand() without its own path munging behaviors kicking
in.
2021-08-17 19:11:30 -04:00
Tim Pope
2039676d97 Respect environment variable overrides when opening terminal 2021-08-17 17:19:46 -04:00
Tim Pope
f047d8250d Improve check for job environment variable support
The patch specified was incorrect for Vim, and this api_info() malarkey
appears to be the only way to check for Neovim 0.5.0 proper.
2021-08-17 17:19:46 -04:00
Tim Pope
2fc1a0017c Accept buffer numbers and dictionaries in FugitiveDetect()
This makes it easier to use FugitiveDetect() to initialize a temp file
that sits outside of the repository.
2021-08-17 17:19:46 -04:00
Tim Pope
80e7c63fb1 Support jump to file under cursor in :Git -p grep
This also adds support for :Git -p status, since we basically already
have an implementation for it.
2021-08-17 17:18:20 -04:00
Tim Pope
2d3e83abe3 Improve git grep argument handling
Add a parsing special case for --count, and improve the handling of
--open-files-in-pager.
2021-08-17 13:07:41 -04:00
Tim Pope
b5e7e1ba24 Don't match :0: as line number in :Ggrep
This is explicitly to help with false positives in surrounding context
while grepping this very file, as :0: is used in numerous places to
reference blobs in the index.  We also use :1: and company in a few
places, but a robust fix is much harder.
2021-08-16 18:28:27 -04:00
Tim Pope
f3e92c7721 Deprecate CTRL-N and CTRL-P 2021-08-14 10:23:57 -04:00
Tim Pope
bec8e7b7c7 Don't override user maps with removal notices
Resolves: https://github.com/tpope/vim-fugitive/issues/1811
2021-08-14 10:23:28 -04:00
Tim Pope
6c53da0783 Use jobs for all Git execution helpers 2021-08-12 07:24:41 -04:00
Tim Pope
b709d9f782 Avoid shell with nvim terminal 2021-08-11 17:21:38 -04:00
Tim Pope
0b53a4daff Override GIT_INDEX_FILE when belonging to wrong repository
GIT_INDEX_FILE is typically set to index.lock when Vim is invoked by
`git commit`.  This effectively breaks Fugitive if you try to use it in
a different repository while inside that Vim session.  To remedy this,
we can instead point GIT_INDEX_FILE at the index file for the relevant
repository.

This also retools command preparation to allow for general purpose
environment variable overrides.
2021-08-11 17:02:26 -04:00
Tim Pope
7a34996886 Use jobs for FileReadCmd 2021-08-11 12:55:18 -04:00
Tim Pope
239089f6e7 Silently ignore trees in s:BlobTemp() 2021-08-11 12:49:37 -04:00
Tim Pope
f11b80022f Use jobs for calls to git update-index
This is our only use of Git that requires writing to stdin, so
shoehorning that behavior onto s:StdoutToFile() frees us from worrying
about that when designing a more general purpose API.
2021-08-11 10:59:54 -04:00
Tim Pope
56561e47a6 Use jobs to capture stdout to file 2021-08-11 04:46:07 -04:00
Tim Pope
8e4a677c7f Fix command preparation when no arguments, only flags 2021-08-10 03:10:03 -04:00
Tim Pope
35872c5dca Make prepare functions idempotent
This is limited to the single argument case so as not to interfere with
using an old command result to seed the Git dir for a new command.
2021-08-10 02:35:52 -04:00
Tim Pope
5853cb0fc3 Tweak documentation for FugitiveResult() 2021-08-10 02:35:52 -04:00
Tim Pope
b20e4145c7 Convert exec path to Vim path before accessing via filesystem 2021-08-10 02:35:52 -04:00
Tim Pope
d1970112f4 Rename #Prepare to #ShellCommand
Shell commands are on their way out.  Let's start reclaiming this verb.
2021-08-10 00:35:17 -04:00
Tim Pope
371a5062d3 Separate out flags when parsing Git arguments
This will enable us to construct an execution result dictionary similar
to FugitiveResult().
2021-08-10 00:25:49 -04:00
Tim Pope
4adf054a3f Fix fugitive#writefile() when staging new file 2021-08-08 22:45:10 -04:00
Tim Pope
19e7604839 Use Git paths when passing temp files to hash-object 2021-08-08 22:36:30 -04:00
Tim Pope
dfae8191f4 Fix FugitiveIsGitDir() 2021-08-08 05:04:38 -04:00
Tim Pope
89c9f96d49 Fix FugitiveHead() for certain arities 2021-08-08 01:39:05 -04:00
Tim Pope
b8ba07f7d8 Improve flexibility of public API argument order
This allows tomfoolery like FugitiveConfig(dir)->FugitiveConfigGet(key).
I'm not sure I want to officially endorse this usage, but if nothing
else it makes interactive debugging a bit more fluid.
2021-08-08 00:48:27 -04:00
Tim Pope
f58ac20359 Generalize FugitiveIsGitDir() to check for buffer Git dir 2021-08-08 00:48:08 -04:00
Tim Pope
55382eb722 Fix usage of index() 2021-08-07 16:19:02 -04:00
Tim Pope
2ee6a48d0b Apply insteadOf to raw remote URLs in addition to remote names
This also retools FugitiveRemoteUrl() argument handling to be a bit more
flexible.
2021-08-07 15:51:07 -04:00
Tim Pope
8def00c247 Homogenize calls to private exec helpers
Replace calls of the form f(dir, arg1, arg2) with f([dir, arg1, arg2]).
2021-08-07 15:51:07 -04:00
Tim Pope
8082606fd0 Fix direct usage of fnameescape()
I plan to lower the minimum Vim version back to 7.0 before shipping 3.4,
which means we can't assume the presence of fnameescape().
2021-08-07 15:51:07 -04:00
Tim Pope
2dc08dfe35 Rename and relocate s:TempCmd() 2021-08-06 22:00:55 -04:00
Tim Pope
a25d4d6961 Fix read command output into buffer with guioptions=! 2021-08-06 21:35:43 -04:00
Tim Pope
2d0f51679c Accept git_dir dict key in FugitivePrepare() 2021-08-06 21:35:43 -04:00
Tim Pope
99e65ce049 Fix error message generation in s:ReplaceCmd() 2021-08-06 21:35:43 -04:00
Tim Pope
ebc828ef7c Minimize use of combined stdout and stderr
Combined stdout and stderr is what system() gives us, so the plugin was
built around it.  But getting the same from jobs is annoying, so let's
eliminate all unnecessary uses of it.
2021-08-06 17:57:57 -04:00
Tim Pope
dc579a0dfb Don't trust git --version with nonzero exit status
This prevents parsing `zsh:1: command not found: git` as version "1:".

References: https://github.com/tpope/vim-fugitive/issues/1801
2021-08-06 17:28:33 -04:00
Tim Pope
e9f913ff8a Fix error message for system() failure with argument list 2021-08-05 17:29:02 -04:00
Tim Pope
3a5d8c8770 Tighten check for PowerShell to match Vim's behavior
Vim only checks for the lowercase "powershell", so we should do the
same.
2021-08-05 17:27:41 -04:00
Tim Pope
1da2c02421 Add Vim version constraint to new PowerShell support
Closes https://github.com/tpope/vim-fugitive/issues/1807
2021-08-05 16:29:40 -04:00
Tim Pope
7a087725ee Encourage FugitiveFind() over FugitiveGitDir() 2021-08-03 11:45:25 -04:00
Tim Pope
24fd3d9599 Eliminate use of ":write !"
This is a prerequisite of eliminating the use of the shell in favor of
direct execution via jobs.
2021-08-03 11:45:25 -04:00
Tim Pope
058ffa406d Fix determining Git version with custom Git command
Resolves: https://github.com/tpope/vim-fugitive/issues/1801
2021-07-29 08:25:05 -04:00
Tim Pope
11aee0ba82 Fix incorrect readfile() arguments 2021-07-28 15:53:56 -04:00
Tim Pope
c417518819 Use absolute path to /usr/bin/env
Based on the prevalence of /usr/bin/env shebangs, I trust it is safe to
hard code this.  Or at least, it's safer than trusting the user not to
create a script called env.
2021-07-27 15:35:35 -04:00
Tim Pope
93f25f6883 Fix omitted Git dir argument
This shouldn't matter in this context since it's designed only to
provoke an error message, but fix it anyways so it stops setting off
mental alarm bells.
2021-07-27 15:35:35 -04:00
Tim Pope
a41329ab7c Get remote URL with config rather than shelling out 2021-07-27 15:35:35 -04:00
Tim Pope
5f87622277 Add methods to config object
Do not rely on these.  The FugitiveConfigGet() family of functions
remains official, for now.
2021-07-26 12:04:52 -04:00
Tim Pope
6bacc1039c Decouple s:SystemError() from Git
Treat lists not as Git arguments but a generic argument list, to enable
avoiding the shell once this becomes job backed.
2021-07-26 12:04:52 -04:00
Tim Pope
d6edaf7a4d Document autocommands 2021-07-26 07:09:30 -04:00
Tim Pope
af5ba43aa3 Reference plugin file as canonical API documentation 2021-07-26 07:09:30 -04:00
Tim Pope
8b0a40dfa2 Remove "soft" qualifier from deprecated commands 2021-07-26 07:09:30 -04:00
Tim Pope
8820f3f89c Document FugitiveRemoteUrl() 2021-07-26 07:09:30 -04:00
Tim Pope
7ab4ab9796 Document FugitiveGitDir() 2021-07-26 07:09:30 -04:00
Tim Pope
295780c507 Tweak phrasing of FugitiveConfig() family documentation 2021-07-26 07:09:30 -04:00
Tim Pope
07b8277475 Move FugitiveHead() documentation to plugin file 2021-07-24 07:56:45 -04:00
Mike Williams
75b2a9a8da Improve PowerShell support with recent Vim
References: https://github.com/tpope/vim-fugitive/pull/1783
2021-07-24 07:28:07 -04:00
Dmytro Meleshko
a7c54990f0 Don't execute autocmds during :GBrowse with range 2021-07-21 18:23:26 -04:00
Tim Pope
de6495ae84 Better support for ssh config
* Respect User and Port in addition to Hostname.
* Support globs and negations in addition to literal host matching.
* Parse global config file in addition to user config file.
* Handle Include declarations.

References: https://github.com/tpope/vim-rhubarb/issues/65
2021-07-17 18:52:27 -04:00
Tim Pope
58516a13c6 Support expanding ## as argument list
Closes https://github.com/tpope/vim-fugitive/issues/1792
2021-07-16 18:38:00 -04:00
Tim Pope
1c2663f516 Use :echomsg for deprecation warnings
Resolves: https://github.com/tpope/vim-fugitive/issues/1789
2021-07-12 15:56:27 -04:00
Tim Pope
b5316d0e96 Avoid stepping on status window in :Gclog/:Gllog
Closes https://github.com/tpope/vim-fugitive/issues/1790
2021-07-12 15:49:14 -04:00
Tim Pope
e9f93be356 Generalize :GBrowse - to all temp buffers 2021-07-12 15:49:14 -04:00
Tim Pope
fd5b553029 Tighten loose regexp 2021-07-12 15:49:14 -04:00
Tim Pope
3e2d531322 Fix error parsing worktree out of config
Resolves: https://github.com/tpope/vim-fugitive/issues/1788
2021-07-11 23:12:13 -04:00
Tim Pope
4cdeff8c33 Remove unnecessary -complete on command with no arguments
References https://github.com/vim/vim/pull/8544
2021-07-11 11:33:31 -04:00
Tim Pope
7412370dc8 Don't assume unrecognized status headers are refs
Every time I experiment with adding a new header this burns me.
2021-07-10 17:56:29 -04:00
Tim Pope
78d41a014e Don't abbreviate :vertical
Change the :Gvdiffsplit definition so that we're consistent with <mods>.
And make everything else consistent with that.
2021-07-10 17:49:17 -04:00
Tim Pope
957d962e06 Error when core.worktree expected but missing 2021-07-09 12:52:20 -04:00
Tim Pope
f920245d6b Avoid spurious window resizing in :Gdiffsplit
Closes https://github.com/tpope/vim-fugitive/issues/1787
2021-07-09 12:52:20 -04:00
Elias Norrby
5551853f34 Fix ternary expression in s:NullError
Only the leading part was removed in ae6f84a.

Fixes #1785
2021-07-08 08:59:46 -04:00
Tim Pope
b498607aa7 Don't assume FugitiveGitDir() is actual directory
This is currently a valid assumption, but it boxes us in.  Instead use
fugitive#Find('.git/'), which is guaranteed to return a path to an
actual directory.

Also use fugitive#Find('.git/refs/..') to determine the common
directory.
2021-07-05 16:45:54 -04:00
Tim Pope
0ec3bb2bdd Use cwd to find Git repository for terminal window
Closes https://github.com/tpope/vim-fugitive/issues/1520
2021-07-05 16:45:54 -04:00
Tim Pope
d11c90ad66 Save filenames from rename rather than splitting on " -> " 2021-07-04 10:36:49 -04:00
Tim Pope
ca03f1d069 Fix write in index with guioptions=! 2021-07-04 10:36:49 -04:00
Tim Pope
ae6f84adf3 Handle empty items when null splitting
This correctly handles the case of multiple consecutive nulls (which I
don't think Git every produces in practice) and also the case of a bogus
newline at the end (which seems to happen with PowerShell).

References https://github.com/tpope/vim-fugitive/pull/1783
2021-07-04 10:36:49 -04:00
Tim Pope
8e0a8abf08 Don't capture trailing count as part of section header
We don't need this, and it gets in the way.
2021-07-03 06:00:36 -04:00
Tim Pope
ca0ff578ad Move config getter implementation into autoload file 2021-07-03 06:00:36 -04:00
Tim Pope
24d1c60364 Unify location of blame maps 2021-06-25 17:14:37 -04:00
Tim Pope
79e2bd381a Fix pager usage for :Git reflog
Resolves: https://github.com/tpope/vim-fugitive/issues/1772
2021-06-19 19:39:21 -04:00
Tim Pope
857c107e5a Fix typo 2021-06-19 12:40:17 -04:00
Tim Pope
be9ff95f27 Avoid guioptions=! issues in :Git --paginate
Resolves: https://github.com/tpope/vim-fugitive/issues/1767
2021-06-11 17:41:37 -04:00
Tim Pope
c26b4b018a Fix shell escaping edge case on win32
This is a proactive fix; no erroneous behavior has been observed.
2021-06-11 17:41:37 -04:00
Tim Pope
41960996e0 Eliminate unnecessary redraw to clear up :Gdiffsplit sync issue
Resolves: https://github.com/tpope/vim-fugitive/issues/1750
2021-06-06 15:38:10 -04:00
Tim Pope
8886d97070 Fix missing bang on function declaration
This causes a error during reloading on older versions of Vim.
2021-06-06 15:38:10 -04:00
Tim Pope
f7f1413ed9 Disable PTY when using win32 Git in WSL
References: https://github.com/tpope/vim-fugitive/issues/1751
2021-06-02 23:00:19 -04:00
Tim Pope
10ed70a9c2 Don't call exists() on invalid function name
References: https://github.com/tpope/vim-fugitive/issues/1751
2021-05-31 19:37:14 -04:00
Tim Pope
9eec18e76b Guard against unloaded plugin in runtime files
This can happen if g:loaded_fugitive is set to disable the plugin, or in
a botched install.
2021-05-31 11:54:04 -04:00
Tim Pope
9871822dd5 Avoid possible hang on failure to start job
References: https://github.com/tpope/vim-fugitive/issues/1751
2021-05-28 17:20:01 -04:00
Tim Pope
6ae064c5aa Tighten match for commit under cursor in temp buffers
Closes https://github.com/tpope/vim-fugitive/issues/1756
2021-05-27 10:37:24 -04:00
Tim Pope
798f65a180 Fix variable reference in s:Remote() 2021-05-27 10:37:24 -04:00
Tim Pope
da8d532b1a Support default value as third FugitiveConfigGet() argument 2021-05-26 09:23:34 -04:00
Tim Pope
bee78a418f Unify use of FugitiveConfig helpers 2021-05-26 09:15:25 -04:00
Tim Pope
28afd12151 Handle quoted strings in g:fugitive_git_executable
Taking the option that was historically a shell command and treating it
as a space-delimited argument list means that there's no longer any way
to include a space in an argument.  Let's rectify that by reusing a
simplified version of the argument parser in s:SplitExpandChain(), which
handles both single and double quoted strings in a way similar to how
shells do it.

Of course, the ideal solution is to just use a list of strings to begin
with.  Support for that is added here as well.

References: https://github.com/tpope/vim-fugitive/issues/1751

# This is the commit message #2:

squash! Accept argument list for g:fugitive_git_executable
2021-05-26 08:53:51 -04:00
Tim Pope
dd01e40106 Use local not upstream branch name for :GBrowse default
When I first wrote this code, I believed push.default=upstream to be the
One True Way, and I used the upstream as the default branch when one
wasn't passed into :GBrowse.  Since then, my preferred workflow has
shifted to push.default=current, with my upstream pointed at the
repository's integration branch (typically master), which means :GBrowse
effectively ignores our current branch, which is less than helpful.

This change eliminates :GBrowse's use of the upstream tracking branch
except in 2 scenarios:

* When push.default=upstream
* When the current branch has never been pushed (since using the current
  branch would result in a 404).
2021-05-26 08:53:51 -04:00
Tim Pope
47a07a0a32 Standardize method for disabling foldmethod=marker
The foldmarker option does appear to be buffer local (despite being
documented as window local), so it should be safe to use this
everywhere.
2021-05-26 08:53:51 -04:00
Tim Pope
7a75c18554 Fix :Git mergetool line offset
This was broken in 895e56daca by
misreading a version constraint.

Resolves: https://github.com/tpope/vim-fugitive/issues/1755
2021-05-26 08:53:51 -04:00
Maksim Odnoletkov
c926aadfaf Fix deprecation error in :GBlame 2021-05-18 14:40:47 -04:00
Tim Pope
0868c30cc0 Tighten up diff highlighting
Closes https://github.com/tpope/vim-fugitive/issues/1747
2021-05-12 13:50:44 -04:00
Tim Pope
32b0d62663 Hunt other tabs for window on :tab Git
I'm not 100% sure if this is the correct (as in least surprising)
behavior, but it seems like as good of place as any to start.

Closes https://github.com/tpope/vim-fugitive/issues/1740
2021-05-02 06:52:14 -04:00
Faisal Shah
8f4a23e663 Fix capitalization 2021-04-23 16:22:00 -04:00
Tim Pope
f7a6097caa Change deprecated q and D maps to errors 2021-04-22 18:20:15 -04:00
Tim Pope
b227b887bb Replace HEAD with @
The @ shortcut for HEAD was introduced in 1.8.5, which we now require.
2021-04-16 15:19:39 -04:00
Tim Pope
895e56daca Require Git 1.8.5 or newer
The removed checks for 1.9 were rounded up 1.8.5 requirements.  This
version has everything we need.
2021-04-16 15:19:39 -04:00
Tim Pope
55e9f2f47e Fix README formatting 2021-04-16 15:19:39 -04:00
Tim Pope
9a1dab0b27 Require Vim 7.4 or newer
This renders a lot of other version checks inside the plugin obsolete,
but I'm going to hold off on cleaning them up until I'm sure this change
is permanent.
2021-04-16 09:27:25 -04:00
Rajit Banerjee
f037ce631a Add note about :Gvdiffsplit 2021-04-16 09:27:16 -04:00
7 changed files with 2098 additions and 990 deletions

View File

@@ -36,11 +36,11 @@ Additional commands are provided for higher level operations:
* View any blob, tree, commit, or tag in the repository with `:Gedit` (and
`:Gsplit`, etc.). For example, `:Gedit HEAD~3:%` loads the current file as
it existed 3 commits ago.
* `:Gdiffsplit` brings up the staged version of the file side by side with the
working tree version. Use Vim's diff handling capabilities to apply changes
to the staged version, and write that buffer to stage the changes. You can
also give an arbitrary `:Gedit` argument to diff against older versions of
the file.
* `:Gdiffsplit` (or `:Gvdiffsplit`) brings up the staged version of the file
side by side with the working tree version. Use Vim's diff handling
capabilities to apply changes to the staged version, and write that buffer
to stage the changes. You can also give an arbitrary `:Gedit` argument to
diff against older versions of the file.
* `:Gread` is a variant of `git checkout -- filename` that operates on the
buffer rather than the file itself. This means you can use `u` to undo it
and you never get any warnings about the file changing outside Vim.
@@ -99,14 +99,9 @@ Install using your favorite package manager, or use Vim's built-in package suppo
> `:Gfetch`?
This behavior was divisive, confusing, and complicated inputting passwords, so
it was removed. Use `:Dispatch git push` for effectively the same behavior,
or provide your own asynchronous `:Gpush` and `:Gfetch` by adding the
following to your vimrc:
command! -bang -bar -nargs=* Gpush execute 'Dispatch<bang> -dir=' .
\ fnameescape(FugitiveGitDir()) 'git push' <q-args>
command! -bang -bar -nargs=* Gfetch execute 'Dispatch<bang> -dir=' .
\ fnameescape(FugitiveGitDir()) 'git fetch' <q-args>
it was removed. Use `:Git! push` to use Fugitive's own asynchronous
execution, or retroactively make `:Git push` asynchronous by pressing
`CTRL-D`.
> So I have a symlink and...

File diff suppressed because it is too large Load Diff

View File

@@ -15,9 +15,12 @@ COMMANDS *fugitive-commands*
These commands are local to the buffers in which they work (generally, buffers
that are part of Git repositories).
*:Git* *fugitive-:G*
*fugitive-:G*
:G [args] Same as :Git, but two characters shorter.
*:Git*
:Git {args} Run an arbitrary git command and display any output.
:G {args} On UNIX this uses a pty and on other platforms it uses
On UNIX this uses a pty and on other platforms it uses
a pipe, which will cause some behavior differences
such as the absence of progress bars. Any file the
command edits (for example, a commit message) will be
@@ -25,17 +28,28 @@ that are part of Git repositories).
resume running the command. A few Git subcommands
have different behavior; these are documented below.
*:Git!*
:Git! {args} Run an arbitrary git command in the background and
stream the output to the preview window. Requires a
Vim with |setbufline()|. Press CTRL-D during an
interactive :Git invocation to switch to this mode
retroactively.
*:Git_--paginate* *:Git_-p*
:Git --paginate {args} Run an arbitrary git command, capture output to a temp
:Git -p {args} file, and |:split| that temp file. Use :0Git to
:G --paginate {args} |:edit| the temp file instead. A temp file is always
:G -p {args} used for commands like diff and log that typically
user a pager, and for any command that has the
pager.<cmd> Git configuration option set.
:Git -p {args} file, and |:split| that temp file. Pass ++curwin as
the first argument to |:edit| the temp file instead.
A temp file is always used for commands like diff and
log that typically uses a pager, and for any command
that has the pager.<cmd> Git configuration option set.
:{range}Git! --paginate {args}
:{range}Git! -p {args} Run an arbitrary git command, and insert the output
after {range} in the current buffer.
*fugitive-summary*
:Git With no arguments, bring up a summary window vaguely
:G akin to git-status. Press g? or see |fugitive-maps|
akin to git-status. Press g? or see |fugitive-maps|
for usage.
*:Git_blame*
@@ -84,13 +98,17 @@ that are part of Git repositories).
*:Git_mergetool*
:Git mergetool [args] Like |:Git_difftool|, but target merge conflicts.
*:Ggrep* *:Gcgrep* *:Git_grep*
:Ggrep[!] [args] |:grep|[!] with git-grep as 'grepprg'.
:Git[!] grep [args]
*:Ggrep* *:Git_grep*
:Ggrep[!] [args] An approximation of |:grep|[!] with git-grep as
:Git[!] grep -O [args] 'grepprg'.
:Ggrep[!] --quiet [args]
:Ggrep[!] -q [args] Like |:Ggrep|, but instead of displaying output, open
the quickfix list.
*:Glgrep*
:Glgrep[!] [args] |:lgrep|[!] with git-grep as 'grepprg'.
:0Git[!] grep [args]
:Glgrep[!] [args] :Ggrep but for |:lgrep|.
:0Git[!] grep -O [args]
*:Gclog*
:Gclog[!] [args] Use git-log [args] to load the commit history into the
@@ -170,10 +188,10 @@ that are part of Git repositories).
:Gdiffsplit [object] Perform a |vimdiff| against the given file, or if a
commit is given, the current file in that commit.
With no argument, the version in the index or work
tree is used. The newer of the two files is placed to
the right or bottom, depending on 'diffopt' and the
width of the window relative to 'textwidth'. Use
Vim's |do| and |dp| to stage and unstage changes.
tree is used, and the work tree version is always
placed to the right or bottom, depending on available
width. Use Vim's |do| and |dp| to stage and unstage
changes.
*:Gdiffsplit!*
:Gdiffsplit! Diff against any and all direct ancestors, retaining
@@ -190,7 +208,10 @@ that are part of Git repositories).
:Gvdiffsplit [object] Like |:Gdiffsplit|, but always split vertically.
*:Ghdiffsplit*
:Ghdiffsplit [object] Like |:Gdiffsplit|, but always split horizontally.
:Gdiffsplit ++novertical [object]
:Ghdiffsplit [object] Like |:Gdiffsplit|, but with "vertical" removed from
'diffopt'. The split will still be vertical if
combined with |:vertical|.
*:GMove*
:GMove {destination} Wrapper around git-mv that renames the buffer
@@ -309,7 +330,7 @@ Navigation maps ~
*fugitive_<CR>*
<CR> Open the file or |fugitive-object| under the cursor.
in a blob, this and similar maps jump to the patch
In a blob, this and similar maps jump to the patch
from the diff where this was added, or where it was
removed if a count was given. If the line is still in
the work tree version, passing a count takes you to
@@ -601,20 +622,56 @@ a statusline, this one matches the default when 'ruler' is set:
>
set statusline=%<%f\ %h%m%r%{FugitiveStatusline()}%=%-14.(%l,%c%V%)\ %P
<
*FugitiveHead(...)* *fugitive#head(...)*
Use FugitiveHead() to return the name of the current branch. If the current
HEAD is detached, FugitiveHead() will return the empty string, unless the
optional argument is given, in which case the hash of the current commit will
be truncated to the given number of characters.
AUTOCOMMANDS *fugitive-autocommands*
A handful of |User| |autocommands| are provided to allow extending and
overriding Fugitive behaviors. Example usage:
>
autocmd User FugitiveBlob,FugitiveStageBlob call s:BlobOverrides()
<
*User_FugitiveTag*
FugitiveTag After loading a tag object.
*User_FugitiveCommit*
FugitiveCommit After loading a commit object.
*User_FugitiveTree*
FugitiveTree After loading a tree (directory) object.
*User_FugitiveBlob*
FugitiveBlob After loading a committed blob (file) object.
*User_FugitiveObject*
FugitiveObject After loading any of the 4 above buffer types.
*User_FugitiveStageBlob*
FugitiveStageBlob After loading a staged blob (file) object. These
buffers are 'modifiable' and oftentimes don't want the
same behavior as the other buffer types.
*User_FugitiveIndex*
FugitiveIndex After loading the |fugitive-summary| buffer.
*User_FugitivePager*
FugitivePager After loading a temp file created by a command like
:Git --paginate or :Git blame.
*User_FugitiveChanged*
FugitiveChanged After any event which can potentially change the
repository, for example, any invocation of |:Git|.
Originally intended for expiring caches, but can have
other uses.
API *fugitive-api*
Officially supported functions are documented inline in plugin/fugitive.vim.
DEPRECATIONS *fugitive-deprecated*
The following commands are softly deprecated in favor of replacements that
adhere to a new naming scheme. They will eventually be removed, but probably
not in the near future.
Remember that |:Git| can be shortened to |:G|, so replacements using it are
just one space character longer than the legacy version.
The following commands are deprecated in favor of replacements that adhere to
a new naming scheme. Remember that |:Git| can be shortened to |:G|, so
replacements using it are just one space character longer than the legacy
version.
*:Gremove* Superseded by |:GRemove|.
*:Gdelete* Superseded by |:GDelete|.
@@ -634,12 +691,19 @@ just one space character longer than the legacy version.
*:Gfetch* Superseded by |:Git| fetch.
*:Glog* Superseded by |:Gclog|.
*:Gstatus* Superseded by |:Git| (with no arguments).
*:Git!* Superseded by |:Git_--paginate|.
*:Gsplit!* Superseded by |:Git_--paginate|.
*:Gvsplit!* Superseded by :vert Git --paginate.
*:Gtabsplit!* Superseded by :tab Git --paginate.
*:Gpedit!* Superseded by :Git! --paginate.
*User_Fugitive*
Fugitive used to support `:autocmd User Fugitive` to run an autocommand after
loading any buffer belonging to a Git repository, but this is being phased
out. Instead, one can leverage regular autocommand events like |BufNewFile|
and |BufReadPost|, and check !empty(FugitiveGitDir()) to confirm Fugitive has
found a repository. See also |fugitive-autocommands| for other, more
selective events.
ABOUT *fugitive-about*
Grab the latest version or report a bug on GitHub:

View File

@@ -1,4 +1,4 @@
if exists("b:did_ftplugin") || !exists('*fugitive#BlameFileType')
if exists("b:did_ftplugin") || !exists("*FugitiveGitDir")
finish
endif
let b:did_ftplugin = 1

View File

@@ -1,6 +1,6 @@
" fugitive.vim - A Git wrapper so awesome, it should be illegal
" Maintainer: Tim Pope <http://tpo.pe/>
" Version: 3.3
" Version: 3.4
" GetLatestVimScripts: 2975 1 :AutoInstall: fugitive.vim
if exists('g:loaded_fugitive')
@@ -10,20 +10,27 @@ let g:loaded_fugitive = 1
let s:bad_git_dir = '/$\|^fugitive:'
" FugitiveGitDir() returns the detected Git dir for the given buffer number,
" or the current buffer if no argument is passed. This will be an empty
" string if no Git dir was found. Use !empty(FugitiveGitDir()) to check if
" Fugitive is active in the current buffer. Do not rely on this for direct
" filesystem access; use FugitiveFind('.git/whatever') instead.
function! FugitiveGitDir(...) abort
if !a:0 || type(a:1) == type(0) && a:1 < 0
if v:version < 703
return ''
elseif !a:0 || type(a:1) == type(0) && a:1 < 0 || a:1 is# get(v:, 'true', -1)
if exists('g:fugitive_event')
return g:fugitive_event
endif
let dir = get(b:, 'git_dir', '')
if empty(dir) && (empty(bufname('')) || &buftype =~# '^\%(nofile\|acwrite\|quickfix\|prompt\)$')
if empty(dir) && (empty(bufname('')) || &buftype =~# '^\%(nofile\|acwrite\|quickfix\|terminal\|prompt\)$')
return FugitiveExtractGitDir(getcwd())
elseif (!exists('b:git_dir') || b:git_dir =~# s:bad_git_dir) && empty(&buftype)
let b:git_dir = FugitiveExtractGitDir(expand('%:p'))
return b:git_dir
endif
return dir =~# s:bad_git_dir ? '' : dir
elseif type(a:1) == type(0)
elseif type(a:1) == type(0) && a:1 isnot# 0
if a:1 == bufnr('') && (!exists('b:git_dir') || b:git_dir =~# s:bad_git_dir) && empty(&buftype)
let b:git_dir = FugitiveExtractGitDir(expand('%:p'))
endif
@@ -48,7 +55,11 @@ endfunction
" exists, call FooReal("foo://bar").
function! FugitiveReal(...) abort
let file = a:0 ? a:1 : @%
if file =~# '^\a\a\+:' || a:0 > 1
if type(file) ==# type({})
let dir = FugitiveGitDir(file)
let tree = s:Tree(dir)
return FugitiveVimPath(empty(tree) ? dir : tree)
elseif file =~# '^\a\a\+:' || a:0 > 1
return call('fugitive#Real', [file] + a:000[1:-1])
elseif file =~# '^/\|^\a:\|^$'
return file
@@ -65,14 +76,10 @@ endfunction
" An optional second argument provides the Git dir, or the buffer number of a
" buffer with a Git dir. The default is the current buffer.
function! FugitiveFind(...) abort
return fugitive#Find(a:0 ? a:1 : bufnr(''), FugitiveGitDir(a:0 > 1 ? a:2 : -1))
endfunction
function! FugitivePath(...) abort
if a:0 > 1
return fugitive#Path(a:1, a:2, FugitiveGitDir(a:0 > 2 ? a:3 : -1))
if a:0 && (type(a:1) ==# type({}) || type(a:1) ==# type(0))
return call('fugitive#Find', a:000[1:-1] + [FugitiveGitDir(a:1)])
else
return FugitiveReal(a:0 ? a:1 : @%)
return fugitive#Find(a:0 ? a:1 : bufnr(''), FugitiveGitDir(a:0 > 1 ? a:2 : -1))
endif
endfunction
@@ -92,14 +99,24 @@ function! FugitiveParse(...) abort
throw v:errmsg
endfunction
" FugitiveGitVersion() queries the version of Git in use. Pass up to 3
" arguments to return a Boolean of whether a certain minimum version is
" available (FugitiveGitVersion(2,3,4) checks for 2.3.4 or higher) or no
" arguments to get a raw string.
function! FugitiveGitVersion(...) abort
return call('fugitive#GitVersion', a:000)
endfunction
" FugitiveResult() returns an object encapsulating the result of the most
" recend :Git command. Will be empty if no result is available. Pass in the
" name of a temp buffer to get the result object for that command instead.
" Contains the following keys:
" recent :Git command. Will be empty if no result is available. During a
" User FugitiveChanged event, this is guaranteed to correspond to the :Git
" command that triggered the event, or be empty if :Git was not the trigger.
" Pass in the name of a temp buffer to get the result object for that command
" instead. Contains the following keys:
"
" * "args": List of command arguments, starting with the subcommand. Will be
" empty for usages like :Git --help.
" * "dir": Git dir of the relevant repository.
" * "git_dir": Git dir of the relevant repository.
" * "exit_status": The integer exit code of the process.
" * "flags": Flags passed directly to Git, like -c and --help.
" * "file": Path to file containing command output. Not guaranteed to exist,
@@ -108,16 +125,44 @@ function! FugitiveResult(...) abort
return call('fugitive#Result', a:000)
endfunction
" FugitivePrepare() constructs a Git command string which can be executed with
" functions like system() and commands like :!. Integer arguments will be
" treated as buffer numbers, and the appropriate relative path inserted in
" their place.
" FugitiveExecute() runs Git with a list of arguments and returns a dictionary
" with the following keys:
"
" If the first argument is a string that looks like a path or an empty string,
" it will be used as the Git dir. If it's a buffer number, the Git dir for
" that buffer will be used. The default is the current buffer.
" * "exit_status": The integer exit code of the process.
" * "stdout": The stdout produced by the process, as a list of lines.
" * "stderr": The stdout produced by the process, as a list of lines.
"
" An optional second argument provides the Git dir, or the buffer number of a
" buffer with a Git dir. The default is the current buffer.
"
" An optional final argument is a callback Funcref, for asynchronous
" execution.
function! FugitiveExecute(args, ...) abort
return call('fugitive#Execute', [a:args] + a:000)
endfunction
" FugitiveShellCommand() turns an array of arugments into a Git command string
" which can be executed with functions like system() and commands like :!.
" Integer arguments will be treated as buffer numbers, and the appropriate
" relative path inserted in their place.
"
" An optional second argument provides the Git dir, or the buffer number of a
" buffer with a Git dir. The default is the current buffer.
function! FugitiveShellCommand(...) abort
return call('fugitive#ShellCommand', a:000)
endfunction
" FugitivePrepare() is a deprecated alias for FugitiveShellCommand(). If you
" are using this in conjunction with system(), consider using
" FugitiveExecute() instead.
function! FugitivePrepare(...) abort
return call('fugitive#Prepare', a:000)
if !exists('s:did_prepare_warning')
let s:did_prepare_warning = 1
echohl WarningMsg
unsilent echomsg 'FugitivePrepare() has been superseded by FugitiveShellCommand()'
echohl NONE
endif
return call('fugitive#ShellCommand', a:000)
endfunction
" FugitiveConfig() get returns an opaque structure that can be passed to other
@@ -125,33 +170,25 @@ endfunction
" when performing multiple config queries. Do not rely on the internal
" structure of the return value as it is not guaranteed. If you want a full
" dictionary of every config value, use FugitiveConfigGetRegexp('.*').
"
" An optional argument provides the Git dir, or the buffer number of a
" buffer with a Git dir. The default is the current buffer. Pass a blank
" string to limit to the global config.
function! FugitiveConfig(...) abort
if a:0 == 2 && (type(a:2) != type({}) || has_key(a:2, 'git_dir'))
return fugitive#Config(a:1, FugitiveGitDir(a:2))
elseif a:0 == 1 && (type(a:1) !=# type('') || a:1 !~# '^[[:alnum:]-]\+\.')
return fugitive#Config(FugitiveGitDir(a:1))
else
return call('fugitive#Config', a:000)
endif
return call('fugitive#Config', a:000)
endfunction
" FugitiveConfigGet() retrieves a Git configuration value. An optional second
" argument provides the Git dir as with FugitiveFind(). Pass a blank string
" to limit to the global config.
" argument can be either the object returned by FugitiveConfig(), or a Git
" dir or buffer number to be passed along to FugitiveConfig().
function! FugitiveConfigGet(name, ...) abort
return call('FugitiveConfig', [a:name] + a:000)
return get(call('FugitiveConfigGetAll', [a:name] + (a:0 ? [a:1] : [])), 0, get(a:, 2, ''))
endfunction
" FugitiveConfigGetAll() is like FugitiveConfigGet() but returns a list of
" all values.
function! FugitiveConfigGetAll(name, ...) abort
if a:0 && type(a:1) ==# type({}) && !has_key(a:1, 'git_dir')
let config = a:1
else
let config = fugitive#Config(FugitiveGitDir(a:0 ? a:1 : -1))
endif
let name = substitute(a:name, '^[^.]\+\|[^.]\+$', '\L&', 'g')
return copy(get(config, name, []))
return call('fugitive#ConfigGetAll', [a:name] + a:000)
endfunction
" FugitiveConfigGetRegexp() retrieves a dictionary of all configuration values
@@ -159,35 +196,66 @@ endfunction
" using a Vim regexp. Second argument has same semantics as
" FugitiveConfigGet().
function! FugitiveConfigGetRegexp(pattern, ...) abort
if a:0 && type(a:1) ==# type({}) && !has_key(a:2, 'git_dir')
let config = a:1
else
let config = fugitive#Config(FugitiveGitDir(a:0 ? a:1 : -1))
endif
let filtered = map(filter(copy(config), 'v:key =~# "\\." && v:key =~# a:pattern'), 'copy(v:val)')
if a:pattern !~# '\\\@<!\%(\\\\\)*\\z[se]'
return filtered
endif
let transformed = {}
for [k, v] in items(filtered)
let k = matchstr(k, a:pattern)
if len(k)
let transformed[k] = v
endif
endfor
return transformed
return call('fugitive#ConfigGetRegexp', [a:pattern] + a:000)
endfunction
" FugitiveRemoteUrl() retrieves the remote URL for the given remote name,
" defaulting to the current branch's remote or "origin" if no argument is
" given. Similar to `git remote get-url`, but also attempts to resolve HTTP
" redirects and SSH host aliases.
"
" An optional second argument provides the Git dir, or the buffer number of a
" buffer with a Git dir. The default is the current buffer.
function! FugitiveRemoteUrl(...) abort
return fugitive#RemoteUrl(a:0 ? a:1 : '', FugitiveGitDir(a:0 > 1 ? a:2 : -1), a:0 > 2 ? a:3 : 0)
return call('fugitive#RemoteUrl', a:000)
endfunction
" FugitiveDidChange() triggers a FugitiveChanged event and reloads the summary
" buffer for the current or given buffer number's repository. You can also
" give the result of a FugitiveExecute() and that context will be made
" available inside the FugitiveChanged() event.
"
" Passing the special argument 0 (the number zero) softly expires summary
" buffers for all repositories. This can be used after a call to system()
" with unclear implications.
function! FugitiveDidChange(...) abort
return call('fugitive#DidChange', a:000)
endfunction
" FugitiveHead() retrieves the name of the current branch. If the current HEAD
" is detached, FugitiveHead() will return the empty string, unless the
" optional argument is given, in which case the hash of the current commit
" will be truncated to the given number of characters.
"
" An optional second argument provides the Git dir, or the buffer number of a
" buffer with a Git dir. The default is the current buffer.
function! FugitiveHead(...) abort
let dir = FugitiveGitDir(a:0 > 1 ? a:2 : -1)
if a:0 && (type(a:1) ==# type({}) || type(a:1) ==# type('') && a:1 !~# '^\d\+$')
let dir = FugitiveGitDir(a:1)
let arg = get(a:, 2, 0)
elseif a:0 > 1
let dir = FugitiveGitDir(a:2)
let arg = a:1
else
let dir = FugitiveGitDir()
let arg = get(a:, 1, 0)
endif
if empty(dir)
return ''
endif
return fugitive#Head(a:0 ? a:1 : 0, dir)
return fugitive#Head(arg, dir)
endfunction
function! FugitivePath(...) abort
if a:0 > 2 && type(a:1) ==# type({})
return fugitive#Path(a:2, a:3, FugitiveGitDir(a:1))
elseif a:0 && type(a:1) ==# type({})
return FugitiveReal(a:0 > 1 ? a:2 : @%)
elseif a:0 > 1
return fugitive#Path(a:1, a:2, FugitiveGitDir(a:0 > 2 ? a:3 : -1))
else
return FugitiveReal(a:0 ? a:1 : @%)
endif
endfunction
function! FugitiveStatusline(...) abort
@@ -202,16 +270,24 @@ function! FugitiveCommonDir(...) abort
if empty(dir)
return ''
endif
return fugitive#CommonDir(dir)
return fugitive#Find('.git/refs/..', dir)
endfunction
function! FugitiveWorkTree(...) abort
return s:Tree(FugitiveGitDir(a:0 ? a:1 : -1))
let tree = s:Tree(FugitiveGitDir(a:0 ? a:1 : -1))
if tree isnot# 0 || a:0 > 1
return tree
else
return ''
endif
endfunction
function! FugitiveIsGitDir(path) abort
let path = substitute(a:path, '[\/]$', '', '') . '/'
return len(a:path) && getfsize(path.'HEAD') > 10 && (
function! FugitiveIsGitDir(...) abort
if !a:0 || type(a:1) !=# type('')
return !empty(call('FugitiveGitDir', a:000))
endif
let path = substitute(a:1, '[\/]$', '', '') . '/'
return len(path) && getfsize(path.'HEAD') > 10 && (
\ isdirectory(path.'objects') && isdirectory(path.'refs') ||
\ getftype(path.'commondir') ==# 'file')
endfunction
@@ -230,9 +306,14 @@ function! s:Tree(path) abort
let config_file = dir . '/config'
if filereadable(config_file)
let config = readfile(config_file,'',10)
call filter(config,'v:val =~# "^\\s*worktree *="')
if len(config) == 1
let worktree = FugitiveVimPath(matchstr(config[0], '= *\zs.*'))
let wt_config = filter(copy(config),'v:val =~# "^\\s*worktree *="')
if len(wt_config) == 1
let worktree = FugitiveVimPath(matchstr(wt_config[0], '= *\zs.*'))
else
call filter(config,'v:val =~# "^\\s*bare *= *false *$"')
if len(config)
let s:worktree_for_dir[dir] = 0
endif
endif
elseif filereadable(dir . '/gitdir')
let worktree = fnamemodify(FugitiveVimPath(readfile(dir . '/gitdir')[0]), ':h')
@@ -270,7 +351,13 @@ function! s:CeilingDirectories() abort
endfunction
function! FugitiveExtractGitDir(path) abort
let path = s:Slash(a:path)
if type(a:path) ==# type({})
return get(a:path, 'git_dir', '')
elseif type(a:path) == type(0)
let path = s:Slash(a:path >= 0 ? bufname(a:path) : bufname(''))
else
let path = s:Slash(a:path)
endif
if path =~# '^fugitive:'
return matchstr(path, '\C^fugitive:\%(//\)\=\zs.\{-\}\ze\%(//\|::\|$\)')
elseif empty(path)
@@ -326,12 +413,15 @@ function! FugitiveExtractGitDir(path) abort
return ''
endfunction
function! FugitiveDetect(path) abort
function! FugitiveDetect(...) abort
if v:version < 703
return ''
endif
if exists('b:git_dir') && b:git_dir =~# '^$\|' . s:bad_git_dir
unlet b:git_dir
endif
if !exists('b:git_dir')
let b:git_dir = FugitiveExtractGitDir(a:path)
let b:git_dir = FugitiveExtractGitDir(a:0 ? a:1 : bufnr(''))
endif
if empty(b:git_dir) || !exists('#User#Fugitive')
return ''
@@ -381,7 +471,7 @@ function! s:ProjectionistDetect() abort
if empty(base)
let base = s:Tree(dir)
endif
if len(base)
if !empty(base)
if exists('+shellslash') && !&shellslash
let base = tr(base, '/', '\')
endif
@@ -392,9 +482,104 @@ function! s:ProjectionistDetect() abort
endif
endfunction
if v:version + has('patch061') < 703
runtime! autoload/fugitive.vim
let s:addr_other = has('patch-8.1.560') || has('nvim-0.5.0') ? '-addr=other' : ''
let s:addr_tabs = has('patch-7.4.542') ? '-addr=tabs' : ''
let s:addr_wins = has('patch-7.4.542') ? '-addr=windows' : ''
if exists(':G') != 2
command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#Complete G exe fugitive#Command(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)
endif
command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#Complete Git exe fugitive#Command(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)
if exists(':Gstatus') != 2 && get(g:, 'fugitive_legacy_commands', 0)
exe 'command! -bang -bar -range=-1' s:addr_other 'Gstatus exe fugitive#Command(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)'
\ '|echohl WarningMSG|echomsg ":Gstatus is deprecated in favor of :Git (with no arguments)"|echohl NONE'
elseif exists(':Gstatus') != 2 && !exists('g:fugitive_legacy_commands')
exe 'command! -bang -bar -range=-1' s:addr_other 'Gstatus'
\ ' echoerr ":Gstatus has been removed in favor of :Git (with no arguments)"'
endif
for s:cmd in ['Commit', 'Revert', 'Merge', 'Rebase', 'Pull', 'Push', 'Fetch', 'Blame']
if exists(':G' . tolower(s:cmd)) != 2 && get(g:, 'fugitive_legacy_commands', 0)
exe 'command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#' . s:cmd . 'Complete G' . tolower(s:cmd)
\ 'echohl WarningMSG|echomsg ":G' . tolower(s:cmd) . ' is deprecated in favor of :Git ' . tolower(s:cmd) . '"|echohl NONE|'
\ 'exe fugitive#Command(<line1>, <count>, +"<range>", <bang>0, "<mods>", "' . tolower(s:cmd) . ' " . <q-args>)'
elseif exists(':G' . tolower(s:cmd)) != 2 && !exists('g:fugitive_legacy_commands')
exe 'command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#' . s:cmd . 'Complete G' . tolower(s:cmd)
\ 'echoerr ":G' . tolower(s:cmd) . ' has been removed in favor of :Git ' . tolower(s:cmd) . '"'
endif
endfor
unlet s:cmd
exe "command! -bar -bang -nargs=? -complete=customlist,fugitive#CdComplete Gcd exe fugitive#Cd(<q-args>, 0)"
exe "command! -bar -bang -nargs=? -complete=customlist,fugitive#CdComplete Glcd exe fugitive#Cd(<q-args>, 1)"
exe 'command! -bang -nargs=? -range=-1' s:addr_wins '-complete=customlist,fugitive#GrepComplete Ggrep exe fugitive#GrepCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)'
exe 'command! -bang -nargs=? -range=-1' s:addr_wins '-complete=customlist,fugitive#GrepComplete Glgrep exe fugitive#GrepCommand(0, <count> > 0 ? <count> : 0, +"<range>", <bang>0, "<mods>", <q-args>)'
if exists(':Glog') != 2 && get(g:, 'fugitive_legacy_commands', 0)
exe 'command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#LogComplete Glog :exe fugitive#LogCommand(<line1>,<count>,+"<range>",<bang>0,"<mods>",<q-args>, "")'
\ '|echohl WarningMSG|echomsg ":Glog is deprecated in favor of :Gclog"|echohl NONE'
elseif exists(':Glog') != 2 && !exists('g:fugitive_legacy_commands')
exe 'command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#LogComplete Glog'
\ ' echoerr ":Glog has been removed in favor of :Gclog"'
endif
exe 'command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#LogComplete Gclog :exe fugitive#LogCommand(<line1>,<count>,+"<range>",<bang>0,"<mods>",<q-args>, "c")'
exe 'command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#LogComplete GcLog :exe fugitive#LogCommand(<line1>,<count>,+"<range>",<bang>0,"<mods>",<q-args>, "c")'
exe 'command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#LogComplete Gllog :exe fugitive#LogCommand(<line1>,<count>,+"<range>",<bang>0,"<mods>",<q-args>, "l")'
exe 'command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#LogComplete GlLog :exe fugitive#LogCommand(<line1>,<count>,+"<range>",<bang>0,"<mods>",<q-args>, "l")'
exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Ge exe fugitive#Open("edit<bang>", 0, "<mods>", <q-args>, [<f-args>])'
exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Gedit exe fugitive#Open("edit<bang>", 0, "<mods>", <q-args>, [<f-args>])'
exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#ReadComplete Gpedit exe fugitive#Open("pedit", <bang>0, "<mods>", <q-args>, [<f-args>])'
exe 'command! -bar -bang -nargs=* -range=-1' s:addr_other '-complete=customlist,fugitive#ReadComplete Gsplit exe fugitive#Open((<count> > 0 ? <count> : "").(<count> ? "split" : "edit"), <bang>0, "<mods>", <q-args>, [<f-args>])'
exe 'command! -bar -bang -nargs=* -range=-1' s:addr_other '-complete=customlist,fugitive#ReadComplete Gvsplit exe fugitive#Open((<count> > 0 ? <count> : "").(<count> ? "vsplit" : "edit!"), <bang>0, "<mods>", <q-args>, [<f-args>])'
exe 'command! -bar -bang -nargs=* -range=-1' s:addr_tabs '-complete=customlist,fugitive#ReadComplete Gtabedit exe fugitive#Open((<count> >= 0 ? <count> : "")."tabedit", <bang>0, "<mods>", <q-args>, [<f-args>])'
if exists(':Gr') != 2
exe 'command! -bar -bang -nargs=* -range=-1 -complete=customlist,fugitive#ReadComplete Gr exe fugitive#ReadCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>, [<f-args>])'
endif
exe 'command! -bar -bang -nargs=* -range=-1 -complete=customlist,fugitive#ReadComplete Gread exe fugitive#ReadCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>, [<f-args>])'
exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Gdiffsplit exe fugitive#Diffsplit(1, <bang>0, "<mods>", <q-args>, [<f-args>])'
exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Ghdiffsplit exe fugitive#Diffsplit(0, <bang>0, "<mods>", <q-args>, [<f-args>])'
exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Gvdiffsplit exe fugitive#Diffsplit(0, <bang>0, "vertical <mods>", <q-args>, [<f-args>])'
exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Gw exe fugitive#WriteCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>, [<f-args>])'
exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Gwrite exe fugitive#WriteCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>, [<f-args>])'
exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Gwq exe fugitive#WqCommand( <line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>, [<f-args>])'
exe 'command! -bar -bang -nargs=0 GRemove exe fugitive#RemoveCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>, [<f-args>])'
exe 'command! -bar -bang -nargs=0 GDelete exe fugitive#DeleteCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>, [<f-args>])'
exe 'command! -bar -bang -nargs=1 -complete=customlist,fugitive#CompleteObject GMove exe fugitive#MoveCommand( <line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>, [<f-args>])'
exe 'command! -bar -bang -nargs=1 -complete=customlist,fugitive#RenameComplete GRename exe fugitive#RenameCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>, [<f-args>])'
if exists(':Gremove') != 2 && get(g:, 'fugitive_legacy_commands', 1)
exe 'command! -bar -bang -nargs=0 Gremove exe fugitive#RemoveCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>, [<f-args>])'
\ '|echohl WarningMSG|echomsg ":Gremove is deprecated in favor of :GRemove"|echohl NONE'
endif
if exists(':Gdelete') != 2 && get(g:, 'fugitive_legacy_commands', 1)
exe 'command! -bar -bang -nargs=0 Gdelete exe fugitive#DeleteCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>, [<f-args>])'
\ '|echohl WarningMSG|echomsg ":Gdelete is deprecated in favor of :GDelete"|echohl NONE'
endif
if exists(':Gmove') != 2 && get(g:, 'fugitive_legacy_commands', 1)
exe 'command! -bar -bang -nargs=1 -complete=customlist,fugitive#CompleteObject Gmove exe fugitive#MoveCommand( <line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>, [<f-args>])'
\ '|echohl WarningMSG|echomsg ":Gmove is deprecated in favor of :GMove"|echohl NONE'
endif
if exists(':Grename') != 2 && get(g:, 'fugitive_legacy_commands', 1)
exe 'command! -bar -bang -nargs=1 -complete=customlist,fugitive#RenameComplete Grename exe fugitive#RenameCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>, [<f-args>])'
\ '|echohl WarningMSG|echomsg ":Grename is deprecated in favor of :GRename"|echohl NONE'
endif
exe 'command! -bar -bang -range=-1 -nargs=* -complete=customlist,fugitive#CompleteObject GBrowse exe fugitive#BrowseCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>, [<f-args>])'
if exists(':Gbrowse') != 2 && get(g:, 'fugitive_legacy_commands', 1)
exe 'command! -bar -bang -range=-1 -nargs=* -complete=customlist,fugitive#CompleteObject Gbrowse exe fugitive#BrowseCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>, [<f-args>])'
\ '|if <bang>1|redraw!|endif|echohl WarningMSG|echomsg ":Gbrowse is deprecated in favor of :GBrowse"|echohl NONE'
endif
if v:version < 703
finish
endif
let g:io_fugitive = {
\ 'simplify': function('fugitive#simplify'),
\ 'resolve': function('fugitive#resolve'),
@@ -427,7 +612,7 @@ augroup fugitive
\ setlocal foldtext=fugitive#Foldtext() |
\ endif
autocmd FileType fugitive
\ call fugitive#MapCfile('fugitive#StatusCfile()')
\ call fugitive#MapCfile('fugitive#PorcelainCfile()')
autocmd FileType gitrebase
\ let &l:include = '^\%(pick\|squash\|edit\|reword\|fixup\|drop\|[pserfd]\)\>' |
\ if &l:includeexpr !~# 'Fugitive' |
@@ -465,92 +650,6 @@ augroup fugitive
autocmd User ProjectionistDetect call s:ProjectionistDetect()
augroup END
let s:addr_other = has('patch-8.1.560') ? '-addr=other' : ''
let s:addr_tabs = has('patch-7.4.542') ? '-addr=tabs' : ''
let s:addr_wins = has('patch-7.4.542') ? '-addr=windows' : ''
if exists(':G') != 2
command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#Complete G exe fugitive#Command(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)
endif
command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#Complete Git exe fugitive#Command(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)
if exists(':Gstatus') != 2 && get(g:, 'fugitive_legacy_commands', 1)
exe 'command! -bang -bar -range=-1' s:addr_other 'Gstatus exe fugitive#Command(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)'
\ '|echohl WarningMSG|echo ":Gstatus is deprecated in favor of :Git (with no arguments)"|echohl NONE'
endif
for s:cmd in ['Commit', 'Revert', 'Merge', 'Rebase', 'Pull', 'Push', 'Fetch', 'Blame']
if exists(':G' . tolower(s:cmd)) != 2 && get(g:, 'fugitive_legacy_commands', 1)
exe 'command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#' . s:cmd . 'Complete G' . tolower(s:cmd)
\ 'echohl WarningMSG|echo ":G' . tolower(s:cmd) . ' is deprecated in favor of :Git ' . tolower(s:cmd) . '"|echohl NONE|'
\ 'exe fugitive#Command(<line1>, <count>, +"<range>", <bang>0, "<mods>", "' . tolower(s:cmd) . ' " . <q-args>)'
endif
endfor
unlet s:cmd
exe "command! -bar -bang -nargs=? -complete=customlist,fugitive#CdComplete Gcd exe fugitive#Cd(<q-args>, 0)"
exe "command! -bar -bang -nargs=? -complete=customlist,fugitive#CdComplete Glcd exe fugitive#Cd(<q-args>, 1)"
exe 'command! -bang -nargs=? -range=-1' s:addr_wins '-complete=customlist,fugitive#GrepComplete Ggrep exe fugitive#GrepCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)'
exe 'command! -bang -nargs=? -range=-1' s:addr_wins '-complete=customlist,fugitive#GrepComplete Gcgrep exe fugitive#GrepCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)'
exe 'command! -bang -nargs=? -range=-1' s:addr_wins '-complete=customlist,fugitive#GrepComplete Glgrep exe fugitive#GrepCommand(0, <count> > 0 ? <count> : 0, +"<range>", <bang>0, "<mods>", <q-args>)'
if exists(':Glog') != 2 && get(g:, 'fugitive_legacy_commands', 1)
exe 'command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#LogComplete Glog :exe fugitive#LogCommand(<line1>,<count>,+"<range>",<bang>0,"<mods>",<q-args>, "")'
\ '|echohl WarningMSG|echo ":Glog is deprecated in favor of :Gclog"|echohl NONE'
endif
exe 'command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#LogComplete Gclog :exe fugitive#LogCommand(<line1>,<count>,+"<range>",<bang>0,"<mods>",<q-args>, "c")'
exe 'command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#LogComplete GcLog :exe fugitive#LogCommand(<line1>,<count>,+"<range>",<bang>0,"<mods>",<q-args>, "c")'
exe 'command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#LogComplete Gllog :exe fugitive#LogCommand(<line1>,<count>,+"<range>",<bang>0,"<mods>",<q-args>, "l")'
exe 'command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#LogComplete GlLog :exe fugitive#LogCommand(<line1>,<count>,+"<range>",<bang>0,"<mods>",<q-args>, "l")'
exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Ge exe fugitive#Open("edit<bang>", 0, "<mods>", <q-args>, [<f-args>])'
exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Gedit exe fugitive#Open("edit<bang>", 0, "<mods>", <q-args>, [<f-args>])'
exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#ReadComplete Gpedit exe fugitive#Open("pedit", <bang>0, "<mods>", <q-args>, [<f-args>])'
exe 'command! -bar -bang -nargs=* -range=-1' s:addr_other '-complete=customlist,fugitive#ReadComplete Gsplit exe fugitive#Open((<count> > 0 ? <count> : "").(<count> ? "split" : "edit"), <bang>0, "<mods>", <q-args>, [<f-args>])'
exe 'command! -bar -bang -nargs=* -range=-1' s:addr_other '-complete=customlist,fugitive#ReadComplete Gvsplit exe fugitive#Open((<count> > 0 ? <count> : "").(<count> ? "vsplit" : "edit!"), <bang>0, "<mods>", <q-args>, [<f-args>])'
exe 'command! -bar -bang -nargs=* -range=-1' s:addr_tabs '-complete=customlist,fugitive#ReadComplete Gtabedit exe fugitive#Open((<count> >= 0 ? <count> : "")."tabedit", <bang>0, "<mods>", <q-args>, [<f-args>])'
if exists(':Gr') != 2
exe 'command! -bar -bang -nargs=* -range=-1 -complete=customlist,fugitive#ReadComplete Gr exe fugitive#ReadCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>, [<f-args>])'
endif
exe 'command! -bar -bang -nargs=* -range=-1 -complete=customlist,fugitive#ReadComplete Gread exe fugitive#ReadCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>, [<f-args>])'
exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Gdiffsplit exe fugitive#Diffsplit(1, <bang>0, "<mods>", <q-args>, [<f-args>])'
exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Ghdiffsplit exe fugitive#Diffsplit(0, <bang>0, "<mods>", <q-args>, [<f-args>])'
exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Gvdiffsplit exe fugitive#Diffsplit(0, <bang>0, "vert <mods>", <q-args>, [<f-args>])'
exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Gw exe fugitive#WriteCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>, [<f-args>])'
exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Gwrite exe fugitive#WriteCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>, [<f-args>])'
exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Gwq exe fugitive#WqCommand( <line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>, [<f-args>])'
exe 'command! -bar -bang -nargs=0 -complete=customlist,fugitive#CompleteObject GRemove exe fugitive#RemoveCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>, [<f-args>])'
exe 'command! -bar -bang -nargs=0 -complete=customlist,fugitive#CompleteObject GDelete exe fugitive#DeleteCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>, [<f-args>])'
exe 'command! -bar -bang -nargs=1 -complete=customlist,fugitive#CompleteObject GMove exe fugitive#MoveCommand( <line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>, [<f-args>])'
exe 'command! -bar -bang -nargs=1 -complete=customlist,fugitive#RenameComplete GRename exe fugitive#RenameCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>, [<f-args>])'
if exists(':Gremove') != 2 && get(g:, 'fugitive_legacy_commands', 1)
exe 'command! -bar -bang -nargs=0 -complete=customlist,fugitive#CompleteObject Gremove exe fugitive#RemoveCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>, [<f-args>])'
\ '|echohl WarningMSG|echo ":Gremove is deprecated in favor of :GRemove"|echohl NONE'
endif
if exists(':Gdelete') != 2 && get(g:, 'fugitive_legacy_commands', 1)
exe 'command! -bar -bang -nargs=0 -complete=customlist,fugitive#CompleteObject Gdelete exe fugitive#DeleteCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>, [<f-args>])'
\ '|echohl WarningMSG|echo ":Gdelete is deprecated in favor of :GDelete"|echohl NONE'
endif
if exists(':Gmove') != 2 && get(g:, 'fugitive_legacy_commands', 1)
exe 'command! -bar -bang -nargs=1 -complete=customlist,fugitive#CompleteObject Gmove exe fugitive#MoveCommand( <line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>, [<f-args>])'
\ '|echohl WarningMSG|echo ":Gmove is deprecated in favor of :GMove"|echohl NONE'
endif
if exists(':Grename') != 2 && get(g:, 'fugitive_legacy_commands', 1)
exe 'command! -bar -bang -nargs=1 -complete=customlist,fugitive#RenameComplete Grename exe fugitive#RenameCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>, [<f-args>])'
\ '|echohl WarningMSG|echo ":Grename is deprecated in favor of :GRename"|echohl NONE'
endif
exe 'command! -bar -bang -range=-1 -nargs=* -complete=customlist,fugitive#CompleteObject GBrowse exe fugitive#BrowseCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>, [<f-args>])'
if exists(':Gbrowse') != 2 && get(g:, 'fugitive_legacy_commands', 1)
exe 'command! -bar -bang -range=-1 -nargs=* -complete=customlist,fugitive#CompleteObject Gbrowse exe fugitive#BrowseCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>, [<f-args>])'
\ '|if <bang>1|redraw!|endif|echohl WarningMSG|echo ":Gbrowse is deprecated in favor of :GBrowse"|echohl NONE'
endif
if get(g:, 'fugitive_no_maps')
finish
endif

View File

@@ -7,8 +7,9 @@ syn spell notoplevel
syn include @fugitiveDiff syntax/diff.vim
syn match fugitiveHeader /^[A-Z][a-z][^:]*:/ nextgroup=fugitiveHash,fugitiveSymbolicRef skipwhite
syn match fugitiveBareHeader /^Bare:/
syn match fugitiveHeader /^[A-Z][a-z][^:]*:/
syn match fugitiveHeader /^Head:/ nextgroup=fugitiveHash,fugitiveSymbolicRef skipwhite
syn match fugitiveHeader /^Pull:\|^Rebase:\|^Merge:\|^Push:/ nextgroup=fugitiveSymbolicRef skipwhite
syn match fugitiveHelpHeader /^Help:/ nextgroup=fugitiveHelpTag skipwhite
syn match fugitiveHelpTag /\S\+/ contained
@@ -26,7 +27,7 @@ syn match fugitiveSymbolicRef /\.\@!\%(\.\.\@!\|[^[:space:][:cntrl:]\:.]\)\+\.\@
syn match fugitiveHash /^\x\{4,\}\S\@!/ contained containedin=@fugitiveSection
syn match fugitiveHash /\S\@<!\x\{4,\}\S\@!/ contained
syn region fugitiveHunk start=/^\%(@@\+ -\)\@=/ end=/^\%([A-Za-z?@]\|$\)\@=/ contains=@fugitiveDiff containedin=@fugitiveSection fold
syn region fugitiveHunk start=/^\%(@@\+ -\)\@=/ end=/^\%([A-Za-z?@]\|$\)\@=/ contains=diffLine,diffRemoved,diffAdded,diffNoEOL containedin=@fugitiveSection fold
for s:section in ['Untracked', 'Unstaged', 'Staged']
exe 'syn region fugitive' . s:section . 'Section start=/^\%(' . s:section . ' .*(\d\+)$\)\@=/ contains=fugitive' . s:section . 'Heading end=/^$/'
@@ -36,7 +37,6 @@ for s:section in ['Untracked', 'Unstaged', 'Staged']
endfor
unlet s:section
hi def link fugitiveBareHeader fugitiveHeader
hi def link fugitiveHelpHeader fugitiveHeader
hi def link fugitiveHeader Label
hi def link fugitiveHelpTag Tag

View File

@@ -1,4 +1,4 @@
if exists("b:current_syntax")
if exists("b:current_syntax") || !exists("*FugitiveGitDir")
finish
endif