1
0
Fork 0
mirror of synced 2024-12-25 00:03:20 -05:00

Update vim-fugitive.

This commit is contained in:
Kurtis Moxley 2022-05-19 21:41:33 +08:00
parent 5d097e66b2
commit 946d949b36
8 changed files with 566 additions and 256 deletions

View file

@ -0,0 +1,2 @@
.git* export-ignore
*.markdown export-ignore

View file

@ -0,0 +1,2 @@
github: tpope
custom: ["https://www.paypal.me/vimpope"]

View file

@ -0,0 +1 @@
/doc/tags

View file

@ -0,0 +1,24 @@
Before reporting a bug, you should try stripping down your Vim configuration
and removing other plugins. The sad truth about VimScript is that it is
fraught with incompatibilities waiting to happen. I'm happy to work around
them where I can, but it's up to you to isolate the conflict.
Fugitive is particularly prone to regressions due to Git version issues,
platform issues, and interactions with other plugins. I end up bisecting a
lot more than other projects, and thus I'm especially meticulous here about
maintaining a clean, readable, history. Squash and force push any requested
changes to a pull request. And if your [commit message
sucks](https://commit.style), I'm not going to accept it. Period.
If your contribution involves adding a configuration option, you are going to
need a very compelling justification for it. Options add a maintenance
burden, support burden, and documentation bloat, and oftentimes can be
achieved much more simply with a custom map or autocommand. If your option
controls an underlying Git command, ask yourself why Git itself does not offer
such configuration.
Beyond that, don't be shy about asking before patching. What takes you hours
might take me minutes simply because I have both domain knowledge and a
perverse knowledge of VimScript so vast that many would consider it a symptom
of mental illness. On the flip side, some ideas I'll reject no matter how
good the implementation is. "Send a patch" is an edge case answer in my book.

View file

@ -0,0 +1,137 @@
# fugitive.vim
Fugitive is the premier Vim plugin for Git. Or maybe it's the premier Git
plugin for Vim? Either way, it's "so awesome, it should be illegal". That's
why it's called Fugitive.
The crown jewel of Fugitive is `:Git` (or just `:G`), which calls any
arbitrary Git command. If you know how to use Git at the command line, you
know how to use `:Git`. It's vaguely akin to `:!git` but with numerous
improvements:
* The default behavior is to directly echo the command's output. Quiet
commands like `:Git add` avoid the dreaded "Press ENTER or type command to
continue" prompt.
* `:Git commit`, `:Git rebase -i`, and other commands that invoke an editor do
their editing in the current Vim instance.
* `:Git diff`, `:Git log`, and other verbose, paginated commands have their
output loaded into a temporary buffer. Force this behavior for any command
with `:Git --paginate` or `:Git -p`.
* `:Git blame` uses a temporary buffer with maps for additional triage. Press
enter on a line to view the commit where the line changed, or `g?` to see
other available maps. Omit the filename argument and the currently edited
file will be blamed in a vertical, scroll-bound split.
* `:Git mergetool` and `:Git difftool` load their changesets into the quickfix
list.
* Called with no arguments, `:Git` opens a summary window with dirty files and
unpushed and unpulled commits. Press `g?` to bring up a list of maps for
numerous operations including diffing, staging, committing, rebasing, and
stashing. (This is the successor to the old `:Gstatus`.)
* This command (along with all other commands) always uses the current
buffer's repository, so you don't need to worry about the current working
directory.
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` (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.
* `:Gwrite` writes to both the work tree and index versions of a file, making
it like `git add` when called from a work tree file and like `git checkout`
when called from the index or a blob in history.
* `:Ggrep` is `:grep` for `git grep`. `:Glgrep` is `:lgrep` for the same.
* `:GMove` does a `git mv` on the current file and changes the buffer name to
match. `:GRename` does the same with a destination filename relative to the
current file's directory.
* `:GDelete` does a `git rm` on the current file and simultaneously deletes
the buffer. `:GRemove` does the same but leaves the (now empty) buffer
open.
* `:GBrowse` to open the current file on the web front-end of your favorite
hosting provider, with optional line range (try it in visual mode). Plugins
are available for popular providers such as [GitHub][rhubarb.vim],
[GitLab][fugitive-gitlab.vim], [Bitbucket][fubitive.vim],
[Gitee][fugitive-gitee.vim], [Pagure][pagure],
[Phabricator][vim-phabricator], [Azure DevOps][fugitive-azure-devops.vim],
and [sourcehut][srht.vim].
[rhubarb.vim]: https://github.com/tpope/vim-rhubarb
[fugitive-gitlab.vim]: https://github.com/shumphrey/fugitive-gitlab.vim
[fubitive.vim]: https://github.com/tommcdo/vim-fubitive
[fugitive-gitee.vim]: https://github.com/linuxsuren/fugitive-gitee.vim
[pagure]: https://github.com/FrostyX/vim-fugitive-pagure
[vim-phabricator]: https://github.com/jparise/vim-phabricator
[fugitive-azure-devops.vim]: https://github.com/cedarbaum/fugitive-azure-devops.vim
[srht.vim]: https://git.sr.ht/~willdurand/srht.vim
Add `%{FugitiveStatusline()}` to `'statusline'` to get an indicator
with the current branch in your statusline.
For more information, see `:help fugitive`.
## Screencasts
* [A complement to command line git](http://vimcasts.org/e/31)
* [Working with the git index](http://vimcasts.org/e/32)
* [Resolving merge conflicts with vimdiff](http://vimcasts.org/e/33)
* [Browsing the git object database](http://vimcasts.org/e/34)
* [Exploring the history of a git repository](http://vimcasts.org/e/35)
## Installation
Install using your favorite package manager, or use Vim's built-in package
support:
mkdir -p ~/.vim/pack/tpope/start
cd ~/.vim/pack/tpope/start
git clone https://tpope.io/vim/fugitive.git
vim -u NONE -c "helptags fugitive/doc" -c q
## FAQ
> What happened to the dispatch.vim backed asynchronous `:Gpush` and
> `:Gfetch`?
This behavior was divisive, confusing, and complicated inputting passwords, so
it was removed. Use `:Git! push` to use Fugitive's own asynchronous
execution, or retroactively make `:Git push` asynchronous by pressing
`CTRL-D`.
> Why am I getting `core.worktree is required when using an external Git dir`?
Git generally sets `core.worktree` for you automatically when necessary, but
if you're doing something weird, or using a third-party tool that does
something weird, you may need to set it manually:
git config core.worktree "$PWD"
This may be necessary even when simple `git` commands seem to work fine
without it.
> So I have a symlink and...
Stop. Just stop. If Git won't deal with your symlink, then Fugitive won't
either. Consider using a [plugin that resolves
symlinks](https://github.com/aymericbeaumet/symlink.vim), or even better,
using fewer symlinks.
## Self-Promotion
Like fugitive.vim? Follow the repository on
[GitHub](https://github.com/tpope/vim-fugitive) and vote for it on
[vim.org](http://www.vim.org/scripts/script.php?script_id=2975). And if
you're feeling especially charitable, follow [tpope](http://tpo.pe/) on
[Twitter](http://twitter.com/tpope) and
[GitHub](https://github.com/tpope).
## License
Copyright (c) Tim Pope. Distributed under the same terms as Vim itself.
See `:help license`.

File diff suppressed because it is too large Load diff

View file

@ -70,8 +70,8 @@ that are part of Git repositories).
O jump to patch or blob in new tab
p jump to patch or blob in preview window
- reblame at commit
~ reblame at [count]th first grandparent
P reblame at [count]th parent (like HEAD^[count])
~ reblame at commit~[count]
P reblame at commit^[count]
*g:fugitive_dynamic_colors*
In the GUI or a 256 color terminal, commit hashes will
@ -98,6 +98,12 @@ that are part of Git repositories).
*:Git_mergetool*
:Git mergetool [args] Like |:Git_difftool|, but target merge conflicts.
Wrappers for Vim built-ins ~
These all directly map onto a built-in Vim command, and generally have names
that prepend "G" to the command they are wrapping. For example, :Ggrep is G
plus |:grep|.
*:Ggrep* *:Git_grep*
:Ggrep[!] [args] An approximation of |:grep|[!] with git-grep as
:Git[!] grep -O [args] 'grepprg'.
@ -113,11 +119,12 @@ that are part of Git repositories).
*:Gclog*
:Gclog[!] [args] Use git-log [args] to load the commit history into the
|quickfix| list. Jumps to the first commit unless [!]
is given.
is given. This command wraps |:cfile|.
The quickfix list can be awkward for many use cases
and exhibits extremely poor performance with larger
data sets. Consider using |:Git| log instead.
data sets. Consider using |:Git| log --oneline
instead.
:{range}Gclog[!] [args] Use git-log -L to load previous revisions of the given
range of the current file into the |quickfix| list.
@ -213,6 +220,13 @@ that are part of Git repositories).
'diffopt'. The split will still be vertical if
combined with |:vertical|.
Other commands ~
These do not directly correspond to any built-in Vim command, and have a
capital letter after the "G" to convey this. For example, the file move
operation has nothing to do with the |:move| built-in, so it is named :GMove,
not :Gmove.
*:GMove*
:GMove {destination} Wrapper around git-mv that renames the buffer
afterward. Add a ! to pass -f.
@ -227,8 +241,9 @@ that are part of Git repositories).
passed. Add a ! to pass -f and forcefully discard the
buffer.
*:GRemove*
*:GRemove* *:GUnlink*
:GRemove Like |:GDelete|, but keep the (now empty) buffer around.
:GUnlink
*:GBrowse*
:GBrowse Open the current file, blob, tree, commit, or tag

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.4
" Version: 3.6
" GetLatestVimScripts: 2975 1 :AutoInstall: fugitive.vim
if exists('g:loaded_fugitive')
@ -25,14 +25,14 @@ function! FugitiveGitDir(...) abort
let dir = get(b:, 'git_dir', '')
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'))
elseif (!exists('b:git_dir') || b:git_dir =~# s:bad_git_dir) && &buftype =~# '^\%(nowrite\)\=$'
let b:git_dir = FugitiveExtractGitDir(bufnr(''))
return b:git_dir
endif
return dir =~# s:bad_git_dir ? '' : dir
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'))
if a:1 == bufnr('') && (!exists('b:git_dir') || b:git_dir =~# s:bad_git_dir) && &buftype =~# '^\%(nowrite\)\=$'
let b:git_dir = FugitiveExtractGitDir(a:1)
endif
let dir = getbufvar(a:1, 'git_dir')
return dir =~# s:bad_git_dir ? '' : dir
@ -210,6 +210,24 @@ function! FugitiveRemoteUrl(...) abort
return call('fugitive#RemoteUrl', a:000)
endfunction
" FugitiveRemote() returns a data structure parsed from the remote URL.
" For example, for remote URL "https://me@example.com:1234/repo.git", the
" returned dictionary will contain the following:
"
" * "scheme": "https"
" * "authority": "user@example.com:1234"
" * "path": "/repo.git" (for SSH URLs this may be a relative path)
" * "pathname": "/repo.git" (always coerced to absolute path)
" * "host": "example.com:1234"
" * "hostname": "example.com"
" * "port": "1234"
" * "user": "me"
" * "path": "/repo.git"
" * "url": "https://me@example.com:1234/repo.git"
function! FugitiveRemote(...) abort
return call('fugitive#Remote', 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
@ -265,12 +283,28 @@ function! FugitiveStatusline(...) abort
return fugitive#Statusline()
endfunction
let s:commondirs = {}
function! FugitiveCommonDir(...) abort
let dir = FugitiveGitDir(a:0 ? a:1 : -1)
if empty(dir)
return ''
endif
return fugitive#Find('.git/refs/..', dir)
if has_key(s:commondirs, dir)
return s:commondirs[dir]
endif
if getfsize(dir . '/HEAD') >= 10
let cdir = get(s:ReadFile(dir . '/commondir', 1), 0, '')
if cdir =~# '^/\|^\a:/'
let s:commondirs[dir] = s:Slash(FugitiveVimPath(cdir))
elseif len(cdir)
let s:commondirs[dir] = simplify(dir . '/' . cdir)
else
let s:commondirs[dir] = dir
endif
else
let s:commondirs[dir] = dir
endif
return s:commondirs[dir]
endfunction
function! FugitiveWorkTree(...) abort
@ -292,6 +326,14 @@ function! FugitiveIsGitDir(...) abort
\ getftype(path.'commondir') ==# 'file')
endfunction
function! s:ReadFile(path, line_count) abort
try
return readfile(a:path, 'b', a:line_count)
catch
return []
endtry
endfunction
let s:worktree_for_dir = {}
let s:dir_for_worktree = {}
function! s:Tree(path) abort
@ -303,23 +345,32 @@ function! s:Tree(path) abort
endif
if !has_key(s:worktree_for_dir, dir)
let s:worktree_for_dir[dir] = ''
let config_file = dir . '/config'
if filereadable(config_file)
let config = readfile(config_file,'',10)
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 *$"')
let ext_wtc_pat = 'v:val =~# "^\\s*worktreeConfig *= *\\%(true\\|yes\\|on\\|1\\) *$"'
let config = s:ReadFile(dir . '/config', 10)
if len(config)
let s:worktree_for_dir[dir] = 0
let ext_wtc_config = filter(copy(config), ext_wtc_pat)
if len(ext_wtc_config) == 1 && filereadable(dir . '/config.worktree')
let config += s:ReadFile(dir . '/config.worktree', 10)
endif
endif
elseif filereadable(dir . '/gitdir')
let worktree = fnamemodify(FugitiveVimPath(readfile(dir . '/gitdir')[0]), ':h')
else
let worktree = fnamemodify(FugitiveVimPath(get(s:ReadFile(dir . '/gitdir', 1), '0', '')), ':h')
if worktree ==# '.'
unlet! worktree
endif
if len(filter(s:ReadFile(FugitiveCommonDir(dir) . '/config', 10), ext_wtc_pat))
let config = s:ReadFile(dir . '/config.worktree', 10)
endif
endif
if len(config)
let wt_config = filter(copy(config), 'v:val =~# "^\\s*worktree *="')
if len(wt_config)
let worktree = FugitiveVimPath(matchstr(wt_config[0], '= *\zs.*'))
elseif !exists('worktree')
call filter(config,'v:val =~# "^\\s*bare *= *true *$"')
if empty(config)
let s:worktree_for_dir[dir] = 0
endif
endif
endif
if exists('worktree')
let s:worktree_for_dir[dir] = s:Slash(resolve(worktree))
@ -341,20 +392,20 @@ function! s:CeilingDirectories() abort
if empty(dir)
let resolve = 0
elseif resolve
call add(s:ceiling_directories, resolve(dir))
call add(s:ceiling_directories, s:Slash(resolve(dir)))
else
call add(s:ceiling_directories, dir)
call add(s:ceiling_directories, s:Slash(dir))
endif
endfor
endif
return s:ceiling_directories + get(g:, 'ceiling_directories', [])
return s:ceiling_directories + get(g:, 'ceiling_directories', [s:Slash(fnamemodify(expand('~'), ':h'))])
endfunction
function! FugitiveExtractGitDir(path) abort
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(''))
let path = s:Slash(a:path > 0 ? bufname(a:path) : bufname(''))
else
let path = s:Slash(a:path)
endif
@ -362,15 +413,14 @@ function! FugitiveExtractGitDir(path) abort
return matchstr(path, '\C^fugitive:\%(//\)\=\zs.\{-\}\ze\%(//\|::\|$\)')
elseif empty(path)
return ''
elseif isdirectory(path)
let path = fnamemodify(path, ':p:s?/$??')
else
let path = fnamemodify(path, ':p:h:s?/$??')
let path = fnamemodify(path, ':p:h')
endif
let pre = substitute(matchstr(path, '^\a\a\+\ze:'), '^.', '\u&', '')
if len(pre) && exists('*' . pre . 'Real')
let path = s:Slash({pre}Real(path))
let path ={pre}Real(path)
endif
let path = s:Slash(path)
let root = resolve(path)
if root !=# path
silent! exe (haslocaldir() ? 'lcd' : exists(':tcd') && haslocaldir(-1) ? 'tcd' : 'cd') '.'
@ -378,11 +428,9 @@ function! FugitiveExtractGitDir(path) abort
let previous = ""
let env_git_dir = len($GIT_DIR) ? s:Slash(simplify(fnamemodify(FugitiveVimPath($GIT_DIR), ':p:s?[\/]$??'))) : ''
call s:Tree(env_git_dir)
while root !=# previous
if root =~# '\v^//%([^/]+/?)?$'
break
endif
if index(s:CeilingDirectories(), root) >= 0
let ceiling_directories = s:CeilingDirectories()
while root !=# previous && root !~# '^$\|^//[^/]*$'
if index(ceiling_directories, root) >= 0
break
endif
if root ==# $GIT_WORK_TREE && FugitiveIsGitDir(env_git_dir)
@ -396,10 +444,10 @@ function! FugitiveExtractGitDir(path) abort
return dir
elseif type ==# 'link' && FugitiveIsGitDir(dir)
return resolve(dir)
elseif type !=# '' && filereadable(dir)
let line = get(readfile(dir, '', 1), 0, '')
elseif type !=# ''
let line = get(s:ReadFile(dir, 1), 0, '')
let file_dir = s:Slash(FugitiveVimPath(matchstr(line, '^gitdir: \zs.*')))
if file_dir !~# '^/\|^\a:' && FugitiveIsGitDir(root . '/' . file_dir)
if file_dir !~# '^/\|^\a:\|^$' && FugitiveIsGitDir(root . '/' . file_dir)
return simplify(root . '/' . file_dir)
elseif len(file_dir) && FugitiveIsGitDir(file_dir)
return file_dir
@ -553,30 +601,44 @@ exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Gwr
exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Gwq exe fugitive#WqCommand( <line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)'
exe 'command! -bar -bang -nargs=0 GRemove exe fugitive#RemoveCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)'
exe 'command! -bar -bang -nargs=0 GUnlink exe fugitive#UnlinkCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)'
exe 'command! -bar -bang -nargs=0 GDelete exe fugitive#DeleteCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)'
exe 'command! -bar -bang -nargs=1 -complete=customlist,fugitive#CompleteObject GMove exe fugitive#MoveCommand( <line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)'
exe 'command! -bar -bang -nargs=1 -complete=customlist,fugitive#RenameComplete GRename exe fugitive#RenameCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)'
if exists(':Gremove') != 2 && get(g:, 'fugitive_legacy_commands', 1)
if exists(':Gremove') != 2 && get(g:, 'fugitive_legacy_commands', 0)
exe 'command! -bar -bang -nargs=0 Gremove exe fugitive#RemoveCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)'
\ '|echohl WarningMSG|echomsg ":Gremove is deprecated in favor of :GRemove"|echohl NONE'
elseif exists(':Gremove') != 2 && !exists('g:fugitive_legacy_commands')
exe 'command! -bar -bang -nargs=0 Gremove echoerr ":Gremove has been removed in favor of :GRemove"'
endif
if exists(':Gdelete') != 2 && get(g:, 'fugitive_legacy_commands', 1)
if exists(':Gdelete') != 2 && get(g:, 'fugitive_legacy_commands', 0)
exe 'command! -bar -bang -nargs=0 Gdelete exe fugitive#DeleteCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)'
\ '|echohl WarningMSG|echomsg ":Gdelete is deprecated in favor of :GDelete"|echohl NONE'
elseif exists(':Gdelete') != 2 && !exists('g:fugitive_legacy_commands')
exe 'command! -bar -bang -nargs=0 Gdelete echoerr ":Gremove has been removed in favor of :GRemove"'
endif
if exists(':Gmove') != 2 && get(g:, 'fugitive_legacy_commands', 1)
if exists(':Gmove') != 2 && get(g:, 'fugitive_legacy_commands', 0)
exe 'command! -bar -bang -nargs=1 -complete=customlist,fugitive#CompleteObject Gmove exe fugitive#MoveCommand( <line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)'
\ '|echohl WarningMSG|echomsg ":Gmove is deprecated in favor of :GMove"|echohl NONE'
elseif exists(':Gmove') != 2 && !exists('g:fugitive_legacy_commands')
exe 'command! -bar -bang -nargs=? -complete=customlist,fugitive#CompleteObject Gmove'
\ 'echoerr ":Gmove has been removed in favor of :GMove"'
endif
if exists(':Grename') != 2 && get(g:, 'fugitive_legacy_commands', 1)
if exists(':Grename') != 2 && get(g:, 'fugitive_legacy_commands', 0)
exe 'command! -bar -bang -nargs=1 -complete=customlist,fugitive#RenameComplete Grename exe fugitive#RenameCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)'
\ '|echohl WarningMSG|echomsg ":Grename is deprecated in favor of :GRename"|echohl NONE'
elseif exists(':Grename') != 2 && !exists('g:fugitive_legacy_commands')
exe 'command! -bar -bang -nargs=? -complete=customlist,fugitive#RenameComplete Grename'
\ 'echoerr ":Grename has been removed in favor of :GRename"'
endif
exe 'command! -bar -bang -range=-1 -nargs=* -complete=customlist,fugitive#CompleteObject GBrowse exe fugitive#BrowseCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)'
if exists(':Gbrowse') != 2 && get(g:, 'fugitive_legacy_commands', 1)
if exists(':Gbrowse') != 2 && get(g:, 'fugitive_legacy_commands', 0)
exe 'command! -bar -bang -range=-1 -nargs=* -complete=customlist,fugitive#CompleteObject Gbrowse exe fugitive#BrowseCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)'
\ '|if <bang>1|redraw!|endif|echohl WarningMSG|echomsg ":Gbrowse is deprecated in favor of :GBrowse"|echohl NONE'
elseif exists(':Gbrowse') != 2 && !exists('g:fugitive_legacy_commands')
exe 'command! -bar -bang -range=-1 -nargs=* -complete=customlist,fugitive#CompleteObject Gbrowse'
\ 'echoerr ":Gbrowse has been removed in favor of :GBrowse"'
endif
if v:version < 703
@ -603,9 +665,8 @@ let g:io_fugitive = {
augroup fugitive
autocmd!
autocmd BufNewFile,BufReadPost *
\ call FugitiveDetect(expand('<amatch>:p'), 0)
autocmd FileType netrw call FugitiveDetect(fnamemodify(get(b:, 'netrw_curdir', expand('<afile>:p')), ':p'), 1)
autocmd BufNewFile,BufReadPost * call FugitiveDetect(+expand('<abuf>'), 0)
autocmd FileType netrw call FugitiveDetect(+expand('<abuf>'), 0)
autocmd FileType git
\ call fugitive#MapCfile()
@ -625,26 +686,26 @@ augroup fugitive
\ endif |
\ let b:undo_ftplugin = get(b:, 'undo_ftplugin', 'exe') . '|setl inex= inc='
autocmd BufReadCmd index{,.lock}
autocmd BufReadCmd index{,.lock} nested
\ if FugitiveIsGitDir(expand('<amatch>:p:h')) |
\ let b:git_dir = s:Slash(expand('<amatch>:p:h')) |
\ exe fugitive#BufReadStatus(v:cmdbang) |
\ elseif filereadable(expand('<amatch>')) |
\ silent doautocmd BufReadPre |
\ keepalt read <amatch> |
\ 1delete_ |
\ keepalt noautocmd read <amatch> |
\ silent 1delete_ |
\ silent doautocmd BufReadPost |
\ else |
\ silent doautocmd BufNewFile |
\ endif
autocmd BufReadCmd fugitive://*//* exe fugitive#BufReadCmd() |
autocmd BufReadCmd fugitive://*//* nested exe fugitive#BufReadCmd() |
\ if &path =~# '^\.\%(,\|$\)' |
\ let &l:path = substitute(&path, '^\.,\=', '', '') |
\ endif
autocmd BufWriteCmd fugitive://*//[0-3]/* exe fugitive#BufWriteCmd()
autocmd FileReadCmd fugitive://*//* exe fugitive#FileReadCmd()
autocmd FileWriteCmd fugitive://*//[0-3]/* exe fugitive#FileWriteCmd()
autocmd BufWriteCmd fugitive://*//[0-3]/* nested exe fugitive#BufWriteCmd()
autocmd FileReadCmd fugitive://*//* nested exe fugitive#FileReadCmd()
autocmd FileWriteCmd fugitive://*//[0-3]/* nested exe fugitive#FileWriteCmd()
if exists('##SourceCmd')
autocmd SourceCmd fugitive://*//* nested exe fugitive#SourceCmd()
endif
@ -678,10 +739,12 @@ function! s:Map(mode, lhs, rhs, flags) abort
let head = substitute(head, '<[^<>]*>$\|.$', '', '')
endwhile
endif
if flags !~# '<unique>' || empty(mapcheck(head.tail, a:mode))
if empty(mapcheck(head.tail, a:mode))
exe a:mode.'map' s:nowait flags head.tail a:rhs
endif
endfunction
call s:Map('c', '<C-R><C-G>', 'fnameescape(fugitive#Object(@%))', '<expr>')
call s:Map('n', 'y<C-G>', ':<C-U>call setreg(v:register, fugitive#Object(@%))<CR>', '<silent>')
nmap <script><silent> <Plug>fugitive:y<C-G> :<C-U>call setreg(v:register, fugitive#Object(@%))<CR>
nmap <script> <Plug>fugitive: <Nop>