73 Commits
v1.1 ... v1.2

Author SHA1 Message Date
Tim Pope
f112f9b830 fugitive.vim 1.2 2011-04-28 23:36:12 -04:00
Tim Pope
0184570176 Revert "Preserve alternate file in :Gmove"
This reverts commit 68b3f3b3d6.  Since
:saveas changes the alternate file, :Gmove should too.
2011-04-28 21:23:47 -04:00
Tim Pope
5e25040a97 Support "(modified content, untracked content)" 2011-04-26 08:44:49 -04:00
Tim Pope
bb191c1939 Really work around Vim parser idiosyncrasy 2011-04-26 08:35:02 -04:00
Tim Pope
4a5f1df129 Fix closing of status window in :Gcommit 2011-04-25 15:17:19 -04:00
Tim Pope
081832380c Work around Vim parser idiosyncrasy 2011-04-25 15:14:55 -04:00
Tim Pope
b11669a2eb Perform automatic :diffupdate after conflict dp 2011-04-25 14:32:42 -04:00
Tim Pope
aebbbd335e Map dp in stage conflict to do the right thing 2011-04-25 11:50:19 -04:00
Tim Pope
3366704c8f Enable - on headings in :Gstatus 2011-04-23 22:15:28 -04:00
Tim Pope
a71120ca8f Cope with new "Changes not staged" heading 2011-04-23 22:06:30 -04:00
Tim Pope
68b3f3b3d6 Preserve alternate file in :Gmove 2011-04-22 13:06:27 -04:00
Tim Pope
3ad9b0d9fa Don't clobber alternate file when committing 2011-04-22 12:59:03 -04:00
Tim Pope
e047558bee Support :Gcommit on older Git versions 2011-04-19 18:24:33 -04:00
Daniel Hahler
4b69204679 Handle non-readable .git dirs.
This can happen when a normal user edits/views some files in /etc, which
is maintained using git/etckeeper, and /etc/.git is only readable by
root.
2011-04-18 03:27:28 -04:00
Tim Pope
3026076ab5 Simplify csh special cases 2011-04-04 23:15:19 -04:00
Alexander Kahn
762bfa7979 Use https for GitHub URL 2011-03-08 05:23:45 +08:00
Tim Pope
57831bb5c1 Add a FAQ 2011-03-06 17:51:05 -05:00
Tim Pope
2e4c9236d6 Implement :Gwq 2011-02-27 14:35:08 -05:00
Tim Pope
3933bfdc57 Prefer ds to dh for horizontal diff map 2011-02-27 13:15:10 -05:00
Tim Pope
fe7f04ebdf Document :Gsdiff and :Gvdiff 2011-02-27 13:15:10 -05:00
Tim Pope
2c0574594d Cease supporting :Gread! 2011-02-27 13:15:09 -05:00
Tim Pope
389efdcf14 Open current branch commits on :Gbrowse HEAD 2011-02-26 20:55:04 -05:00
Tim Pope
1e6d7c8a40 Fix use of throw 2011-02-26 20:12:34 -05:00
Tim Pope
d5f8446158 Let :Gdiff :/ diff against the work tree version 2011-02-26 18:55:47 -05:00
Tim Pope
383b2a43df Handle arbitrary :Gbrowse revision 2011-02-26 17:59:15 -05:00
Tim Pope
95311ab2d9 Ignore rev-parse warnings 2011-02-26 13:45:24 -05:00
Tim Pope
ca4e18c81f Allow -/ and :/ to refer to current work tree file 2011-02-26 12:39:19 -05:00
Tim Pope
1eeff6c349 :Gbrowse takes remote tracking branch into account 2011-02-24 16:31:50 -05:00
Tim Pope
9e05d7ee03 Allow :Gbrowse @git://... 2011-02-24 15:57:00 -05:00
Daniel Hahler
55fac5dd74 Fix typo: "flie" => "file" 2011-02-23 00:14:18 +08:00
Tim Pope
d6615891c2 Provide :Gbrowse to open code in web browser 2011-02-21 17:54:23 -05:00
Tim Pope
af9d44f91b Add filetype specific tags 2011-02-07 15:04:28 -05:00
Michael Geddes
156123520b Handle win32 change in behaviour of fnamemodify in 7.3
Signed-off-by: Michael Geddes <vimmer@frog.wheelycreek.net>
2011-01-09 17:40:37 -05:00
Tim Pope
33ea0aa4e7 Support submodules in :Gstatus 2011-01-08 16:52:40 -05:00
Tim Pope
9bbea8a2a1 Work around Vim parser idiosyncrasy 2011-01-04 15:04:47 -05:00
Tim Pope
882597d17e Fix trailing slash issues 2011-01-04 14:59:59 -05:00
Tim Pope
64ead8ea1c Don't overwrite paste buffer in :Gread 2010-12-27 23:50:32 -05:00
Tim Pope
ab35c2d9ab Allow :Gmove in a directory 2010-12-27 23:27:03 -05:00
Tim Pope
affce710e2 Mitigate conflict with DirDiff plugin
This plugin tries to be helpful about disabling diff mode when a diff
window closes, which was confusing DirDiff. We can mitigate that but
only disabling diff mode when b:git_dir matches.
2010-11-13 20:26:53 -05:00
Tim Pope
a5e9b2e93e Fix blind copy/paste 2010-11-13 20:15:53 -05:00
Tim Pope
22a832f958 Fix focus anomaly when closing a split
This is seemingly the cause of an incompatibility with the DirDiff
plugin.
2010-11-13 20:04:34 -05:00
Tim Pope
e954d364f5 Rename :Ghdiff to :Gsdiff 2010-11-05 19:45:08 -04:00
Tim Pope
0b4e32180b Fix restoration of :lcd after :Gblame
The restore of :lcd was happening after the split, meaning it was taking
effect in the wrong window.
2010-11-05 18:17:26 -04:00
Tim Pope
b3f38c4886 Add :Gvdiff and :Ghdiff aliases
I haven't decided if this will become the preferred interface or not.
2010-10-24 17:52:59 -04:00
Tim Pope
6ba88784a2 Add :Gvdiff alias for :Gdiff 2010-10-24 17:52:24 -04:00
Tim Pope
e64870df9c Fix error after empty commit message 2010-10-24 13:40:07 -04:00
Tim Pope
de602e3676 Remove debugging statement 2010-10-24 13:39:58 -04:00
Tim Pope
119fd9e1ad <C-N> and <C-P> in :Gstatus cycle between files 2010-09-15 23:24:05 -04:00
Tim Pope
24efca8f4f Fix :Gcommit with noisy pre-commit hook 2010-09-09 11:17:45 -04:00
Tim Pope
9d02bf0868 :Gwrite! calls git add --force 2010-08-21 22:52:45 -04:00
Tim Pope
45fe471b44 Attempt to address GitHub issue #16 2010-08-18 22:20:28 -04:00
Tim Pope
a8bd148683 Rename fugitive#buffer().name() to spec()
In rails.vim, path() and name() have the opposite (and dare I say more
intuitive) semantic of that found in fugitive.vim.  An outright switch
would be a little violent, so for now, rename name() to spec() (as in
"file spec").
2010-08-04 09:29:22 -04:00
Tim Pope
ea89d6ec12 FileType does not have <amatch> as path 2010-08-04 09:29:22 -04:00
Tim Pope
6ea8f2a2ae Update email 2010-08-04 09:29:22 -04:00
Tim Pope
15282dde17 Tighten check of 'tags' for duplicate 2010-08-03 09:22:27 -04:00
Tim Pope
bdab318cc6 Fix setting of 'tags' 2010-08-02 16:52:39 -04:00
Tim Pope
ea588a104c Point 'tags' at .git/tags 2010-07-28 14:45:48 -04:00
Tim Pope
2b9faa8c7f Press dh in :Gstatus to do a horizontal diff 2010-07-28 09:14:25 -04:00
Tim Pope
562ab96b2f Whitespace fix 2010-07-26 11:22:52 -04:00
Tim Pope
a1cc7f3fbd Document :Gdiff! 2010-07-25 21:53:12 -04:00
Vincent Driessen
a8109a541d Ignore tags file that Vim generates. 2010-07-19 07:44:53 +08:00
Michael Geddes
794c21484d Expose config settings and user signature.
Adds config() and user() to the fugitive#buffer() interface.

Signed-off-by: Michael Geddes <vimmer@frog.wheelycreek.net>
2010-06-28 14:39:21 -04:00
Tim Pope
7390538db0 Jump to horizontal diff on "index ..." lines 2010-06-28 11:50:44 -04:00
Tim Pope
559425cafa Replace "Use" with clearer "Press" 2010-06-25 21:30:15 -04:00
Tim Pope
8fcc5cb349 Fix :Gblame with csh 2010-06-08 11:08:05 -04:00
Michael Geddes
3121f01f59 Allow applying from git diffs to work under win32.
The introduction of using 'chcp' in the git.cmd wrapper was causing the
piped in values to be gobbled by the chcp in the call to update-index.

Signed-off-by: Michael Geddes <vimmer@frog.wheelycreek.net>
2010-06-02 23:44:42 -04:00
Tim Pope
ffcc12de5f Fix endif error 2010-06-02 23:43:33 -04:00
Tim Pope
6c44c4795e Only :diffoff in 'diff' buffers 2010-05-25 16:48:34 -04:00
Tim Pope
27e2212ac0 Fix indent 2010-05-25 16:32:09 -04:00
Tim Pope
2ed441fde7 Use window not buffer variable for window restore 2010-05-25 15:34:53 -04:00
Tim Pope
66812106e8 Add missing clear of augroup 2010-05-25 15:32:35 -04:00
Tim Pope
24c5a45431 Disable diff more more aggressively 2010-04-14 11:05:53 -04:00
Tim Pope
1f0bc8cff9 :Gdiff! splits horizontally 2010-04-14 10:49:21 -04:00
4 changed files with 495 additions and 94 deletions

1
.gitignore vendored Normal file
View File

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

View File

@@ -11,13 +11,14 @@ version of the file side by side with the working tree version and use
Vim's diff handling capabilities to stage a subset of the file's
changes.
Bring up the output of `git status` with `:Gstatus`. Use `-` to
Bring up the output of `git status` with `:Gstatus`. Press `-` to
`add`/`reset` a file's changes, or `p` to `add`/`reset` `--patch` that
mofo. And guess what `:Gcommit` does!
`:Gblame` brings up an interactive vertical split with `git blame`
output. Press enter on a line to reblame the file as it stood in that
commit, or `o` to open that commit in a split.
commit, or `o` to open that commit in a split. When you're done, use
`:Gedit` in the historic buffer to go back to the work tree version.
`:Gmove` does a `git mv` on a file and simultaneously renames the
buffer. `:Gremove` does a `git rm` on a file and simultaneously deletes
@@ -35,6 +36,10 @@ and you never get any warnings about the file changing outside Vim.
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.
Use `:Gbrowse` to open the current file on GitHub, with optional line
range (try it in visual mode!). If your current repository isn't on
GitHub, `git instaweb` will be spun up instead.
Add `%{fugitive#statusline()}` to `'statusline'` to get an indicator
with the current branch in (surprise!) your statusline.
@@ -43,3 +48,23 @@ Oh, and of course there's `:Git` for running any arbitrary command.
Like fugitive.vim? Follow the repository on
[GitHub](http://github.com/tpope/vim-fugitive) and vote for it on
[vim.org](http://www.vim.org/scripts/script.php?script_id=2975).
FAQ
---
> I installed the plugin and started Vim. Why don't any of the commands
> exist?
Fugitive cares about the current file, not the current working
directory. Edit a file from the repository.
> I opened a new tab. Why don't any of the commands exist?
Fugitive cares about the current file, not the current working
directory. Edit a file from the repository.
> I changed the current working directory. Why do all the commands use
> the old directory?
Fugitive cares about the current file, not the current working
directory. Edit a file from the repository.

View File

@@ -1,6 +1,6 @@
*fugitive.txt* A Git wrapper so awesome, it should be illegal
Author: Tim Pope <vimNOSPAM@tpope.info> *fugitive-author*
Author: Tim Pope <vimNOSPAM@tpope.org> *fugitive-author*
License: Same terms as Vim itself (see |license|)
This plugin is only available if 'compatible' is not set.
@@ -51,10 +51,15 @@ that are part of Git repositories).
*fugitive-:Gstatus*
:Gstatus Bring up the output of git-status in the preview
window. Press D to |:Gdiff| the file on the cursor
line. Press - to stage or unstage the file on the
cursor line. Press p to do so on a per hunk basis
(--patch). Press C to invoke |:Gcommit|.
window. In addition to standard motions, you can
use <C-N> and <C-P> to jump from filename to
filename. Press C to invoke |:Gcommit|. Press D to
|:Gdiff| the file on the cursor line, or ds to
|:Gsdiff|. Press - to stage or unstage the file on
the cursor line. Press p to do so on a per hunk basis
(--patch). All of D, -, and p have a different,
sensible (and hopefully intuitive) behavior when
invoked on a heading rather than a file name.
*fugitive-:Gcommit*
:Gcommit [args] A wrapper around git-commit. If there is nothing
@@ -102,9 +107,6 @@ that are part of Git repositories).
:{range}Gread [revision]
|:read| in a |fugitive-revision| after {range}.
*fugitive-:Gread!*
:Gread! [revision] Deprecated synonym for |:Gread|.
*fugitive-:Gwrite*
:Gwrite Write to the current file's path and stage the results.
When run in a work tree file, it is effectively git
@@ -118,6 +120,13 @@ that are part of Git repositories).
:0:foo.txt or even :0 to write to just that stage in
the index.
*fugitive-:Gwq*
:Gwq [path] Like |:Gwrite| followed by |:quit| if the write
succeeded.
:Gwq! [path] Like |:Gwrite|! followed by |:quit|! if the write
succeeded.
*fugitive-:Gdiff*
:Gdiff [revision] Perform a |vimdiff| against the current file in the
given revision. With no argument, the version in the
@@ -127,6 +136,12 @@ that are part of Git repositories).
to the right. Use |do| and |dp| and write to the
index file to simulate "git add --patch".
*fugitive-:Gsdiff*
:Gsdiff [revision] Like |:Gdiff|, but split horizontally.
*fugitive-:Gvdiff*
:Gvdiff [revision] Identical to |:Gdiff|. For symmetry with |:Gsdiff|.
*fugitive-:Gmove*
:Gmove {destination} Wrapper around git-mv that renames the buffer
afterward. The destination is relative to the current
@@ -148,6 +163,28 @@ that are part of Git repositories).
:[range]Gblame [flags] Run git-blame on the given range.
*fugitive-:Gbrowse*
:[range]Gbrowse If the remote for the current branch is on GitHub,
open the current file, blob, tree, commit, or tag
(with git-web--browse) on GitHub. Otherwise, open the
current file, blob, tree, commit, or tag in
git-instaweb (if you have issues, verify you can run
"git instaweb" from a terminal). If a range is given,
it is appropriately appended to the URL as an anchor.
:[range]Gbrowse! Like :Gbrowse, but put the URL on the clipboard rather
than opening it.
:[range]Gbrowse {revision}
Like :Gbrowse, but for a given |fugitive-revision|. A
useful value here is -, which ties the URL to the
latest commit rather than a volatile branch.
:[range]Gbrowse [...]@{remote}
Force using the given remote rather than the remote
for the current branch. The remote is used to
determine which GitHub repository to link to.
MAPPINGS *fugitive-mappings*
These maps are available in Git objects.

View File

@@ -1,6 +1,6 @@
" fugitive.vim - A Git wrapper so awesome, it should be illegal
" Maintainer: Tim Pope <vimNOSPAM@tpope.org>
" Version: 1.1
" Version: 1.2
" GetLatestVimScripts: 2975 1 :AutoInstall: fugitive.vim
if exists('g:loaded_fugitive') || &cp
@@ -108,7 +108,7 @@ function! s:ExtractGitDir(path) abort
let ofn = ""
let nfn = fn
while fn != ofn
if isdirectory(fn . '/.git')
if filereadable(fn . '/.git/HEAD')
return s:sub(simplify(fnamemodify(fn . '/.git',':p')),'\W$','')
elseif fn =~ '\.git$' && filereadable(fn . '/HEAD')
return s:sub(simplify(fnamemodify(fn,':p')),'\W$','')
@@ -132,19 +132,25 @@ function! s:Detect(path)
if exists('b:git_dir')
silent doautocmd User Fugitive
cnoremap <expr> <buffer> <C-R><C-G> fugitive#buffer().rev()
let buffer = fugitive#buffer()
if expand('%:p') =~# '//'
let buffer = fugitive#buffer()
call buffer.setvar('&path',s:sub(buffer.getvar('&path'),'^\.%(,|$)',''))
endif
if b:git_dir !~# ',' && stridx(buffer.getvar('&tags'),b:git_dir.'/tags') == -1
if &filetype != ''
call buffer.setvar('&tags',buffer.getvar('&tags').','.b:git_dir.'/'.&filetype.'.tags')
endif
call buffer.setvar('&tags',buffer.getvar('&tags').','.b:git_dir.'/tags')
endif
endif
endfunction
augroup fugitive
autocmd!
autocmd BufNewFile,BufReadPost * call s:Detect(expand('<amatch>:p'))
autocmd FileType netrw call s:Detect(expand('<amatch>:p'))
autocmd FileType netrw call s:Detect(expand('<afile>:p'))
autocmd VimEnter * if expand('<amatch>')==''|call s:Detect(getcwd())|endif
autocmd BufWinLeave * execute getbufvar(+expand('<abuf>'), 'fugitive_restore')
autocmd BufWinLeave * execute getwinvar(+winnr(), 'fugitive_restore')
augroup END
" }}}1
@@ -248,8 +254,8 @@ endfunction
function! s:repo_rev_parse(rev) dict abort
let hash = self.git_chomp('rev-parse','--verify',a:rev)
if hash =~ '^\x\{40\}$'
return hash
if hash =~ '\<\x\{40\}$'
return matchstr(hash,'\<\x\{40\}$')
endif
call s:throw('rev-parse '.a:rev.': '.hash)
endfunction
@@ -351,7 +357,7 @@ endfunction
function! s:buffer_type(...) dict abort
if self.getvar('fugitive_type') != ''
let type = self.getvar('fugitive_type')
elseif fnamemodify(self.name(),':p') =~# '.\git/refs/\|\.git/\w*HEAD$'
elseif fnamemodify(self.spec(),':p') =~# '.\git/refs/\|\.git/\w*HEAD$'
let type = 'head'
elseif self.getline(1) =~ '^tree \x\{40\}$' && self.getline(2) == ''
let type = 'tree'
@@ -359,11 +365,11 @@ function! s:buffer_type(...) dict abort
let type = 'tree'
elseif self.getline(1) =~ '^\d\{6\} \x\{40\}\> \d\t'
let type = 'index'
elseif isdirectory(self.name())
elseif isdirectory(self.spec())
let type = 'directory'
elseif self.name() == ''
elseif self.spec() == ''
let type = 'null'
elseif filereadable(self.name())
elseif filereadable(self.spec())
let type = 'file'
else
let type = ''
@@ -375,42 +381,61 @@ function! s:buffer_type(...) dict abort
endif
endfunction
if has('win32')
function! s:buffer_spec() dict abort
let bufname = bufname(self['#'])
let retval = ''
for i in split(bufname,'[^:]\zs\\')
let retval = fnamemodify((retval==''?'':retval.'\').i,':.')
endfor
return s:shellslash(fnamemodify(retval,':p'))
endfunction
else
function! s:buffer_spec() dict abort
let bufname = bufname(self['#'])
return s:shellslash(bufname == '' ? '' : fnamemodify(bufname,':p'))
endfunction
endif
function! s:buffer_name() dict abort
let bufname = bufname(self['#'])
return s:shellslash(bufname == '' ? '' : fnamemodify(bufname,':p'))
return self.spec()
endfunction
function! s:buffer_commit() dict abort
return matchstr(self.name(),'^fugitive://.\{-\}//\zs\w*')
return matchstr(self.spec(),'^fugitive://.\{-\}//\zs\w*')
endfunction
function! s:buffer_path(...) dict abort
let rev = matchstr(self.name(),'^fugitive://.\{-\}//\zs.*')
let rev = matchstr(self.spec(),'^fugitive://.\{-\}//\zs.*')
if rev != ''
let rev = s:sub(rev,'\w*','')
else
let rev = self.name()[strlen(self.repo().tree()) : -1]
let rev = self.spec()[strlen(self.repo().tree()) : -1]
endif
return s:sub(rev,'^/',a:0 ? a:1 : '')
return s:sub(s:sub(rev,'.\zs/$',''),'^/',a:0 ? a:1 : '')
endfunction
function! s:buffer_rev() dict abort
let rev = matchstr(self.name(),'^fugitive://.\{-\}//\zs.*')
let rev = matchstr(self.spec(),'^fugitive://.\{-\}//\zs.*')
if rev =~ '^\x/'
return ':'.rev[0].':'.rev[2:-1]
elseif rev =~ '.'
return s:sub(rev,'/',':')
elseif self.name() =~ '\.git/index$'
elseif self.spec() =~ '\.git/index$'
return ':'
elseif self.name() =~ '\.git/refs/\|\.git/.*HEAD$'
return self.name()[strlen(self.repo().dir())+1 : -1]
elseif self.spec() =~ '\.git/refs/\|\.git/.*HEAD$'
return self.spec()[strlen(self.repo().dir())+1 : -1]
else
return self.path()
endif
endfunction
function! s:buffer_sha1() dict abort
if self.name() =~ '^fugitive://' || self.name() =~ '\.git/refs/\|\.git/.*HEAD$'
if self.spec() =~ '^fugitive://' || self.spec() =~ '\.git/refs/\|\.git/.*HEAD$'
return self.repo().rev_parse(self.rev())
else
return ''
@@ -420,6 +445,8 @@ endfunction
function! s:buffer_expand(rev) dict abort
if a:rev =~# '^:[0-3]$'
let file = a:rev.self.path(':')
elseif a:rev =~# '^[-:]/$'
let file = '/'.self.path()
elseif a:rev =~# '^-'
let file = 'HEAD^{}'.a:rev[1:-1].self.path(':')
elseif a:rev =~# '^@{'
@@ -430,7 +457,7 @@ function! s:buffer_expand(rev) dict abort
else
let file = a:rev
endif
return s:sub(file,'\%$',self.path())
return s:sub(s:sub(file,'\%$',self.path()),'\.\@<=/$','')
endfunction
function! s:buffer_containing_commit() dict abort
@@ -443,7 +470,7 @@ function! s:buffer_containing_commit() dict abort
endif
endfunction
call s:add_methods('buffer',['getvar','setvar','getline','repo','type','name','commit','path','rev','sha1','expand','containing_commit'])
call s:add_methods('buffer',['getvar','setvar','getline','repo','type','spec','name','commit','path','rev','sha1','expand','containing_commit'])
" }}}1
" Git {{{1
@@ -538,10 +565,11 @@ function! fugitive#reload_status() abort
endfor
endfunction
function! s:StageDiff() abort
function! s:StageDiff(...) abort
let cmd = a:0 ? a:1 : 'Gdiff'
let section = getline(search('^# .*:$','bnW'))
let line = getline('.')
let filename = matchstr(line,'^#\t\%([[:alpha:] ]\+: *\)\=\zs.*')
let filename = matchstr(line,'^#\t\%([[:alpha:] ]\+: *\)\=\zs.\{-\}\ze\%( (new commits)\)\=$')
if filename ==# '' && section == '# Changes to be committed:'
return 'Git diff --cached'
elseif filename ==# ''
@@ -549,13 +577,13 @@ function! s:StageDiff() abort
elseif line =~# '^#\trenamed:' && filename =~ ' -> '
let [old, new] = split(filename,' -> ')
execute 'Gedit '.s:fnameescape(':0:'.new)
return 'Gdiff HEAD:'.s:fnameescape(old)
return cmd.' HEAD:'.s:fnameescape(old)
elseif section == '# Changes to be committed:'
execute 'Gedit '.s:fnameescape(':0:'.filename)
return 'Gdiff -'
return cmd.' -'
else
execute 'Gedit '.s:fnameescape('/'.filename)
return 'Gdiff'
return cmd
endif
endfunction
@@ -564,10 +592,34 @@ function! s:StageToggle(lnum1,lnum2) abort
let output = ''
for lnum in range(a:lnum1,a:lnum2)
let line = getline(lnum)
if getline('.') == '# Changes to be committed:'
return 'Gcommit'
let repo = s:repo()
if line ==# '# Changes to be committed:'
call repo.git_chomp_in_tree('reset','-q')
silent! edit!
1
if !search('^# Untracked files:$','W')
call search('^# Change','W')
endif
return ''
elseif line =~# '^# Change\%(d but not updated\|s not staged for commit\):$'
call repo.git_chomp_in_tree('add','-u')
silent! edit!
1
if !search('^# Untracked files:$','W')
call search('^# Change','W')
endif
return ''
elseif line ==# '# Untracked files:'
" Work around Vim parser idiosyncrasy
call repo.git_chomp_in_tree('add','-N','.')
silent! edit!
1
if !search('^# Change\%(d but not updated\|s not staged for commit\):$','W')
call search('^# Change','W')
endif
return ''
endif
let filename = matchstr(line,'^#\t\%([[:alpha:] ]\+: *\)\=\zs.*')
let filename = matchstr(line,'^#\t\%([[:alpha:] ]\+: *\)\=\zs.\{-\}\ze\%( (\a\+ [[:alpha:], ]\+)\)\=$')
if filename ==# ''
continue
endif
@@ -586,7 +638,7 @@ function! s:StageToggle(lnum1,lnum2) abort
else
let cmd = ['add','--',filename]
endif
let output .= call(s:repo().git_chomp_in_tree,cmd,s:repo())."\n"
let output .= call(repo.git_chomp_in_tree,cmd,s:repo())."\n"
endfor
if exists('first_filename')
let jump = first_filename
@@ -597,7 +649,7 @@ function! s:StageToggle(lnum1,lnum2) abort
silent! edit!
1
redraw
call search('^#\t\%([[:alpha:] ]\+: *\)\=\V'.jump.'\$','W')
call search('^#\t\%([[:alpha:] ]\+: *\)\=\V'.jump.'\%( (new commits)\)\=\$','W')
endif
echo s:sub(s:gsub(output,'\n+','\n'),'\n$','')
catch /^fugitive:/
@@ -612,12 +664,12 @@ function! s:StagePatch(lnum1,lnum2) abort
for lnum in range(a:lnum1,a:lnum2)
let line = getline(lnum)
if line == '# Changes to be committed:'
if line ==# '# Changes to be committed:'
return 'Git reset --patch'
elseif line == '# Changed but not updated:'
elseif line =~# '^# Change\%(d but not updated\|s not staged for commit\):$'
return 'Git add --patch'
endif
let filename = matchstr(line,'^#\t\%([[:alpha:] ]\+: *\)\=\zs.*')
let filename = matchstr(line,'^#\t\%([[:alpha:] ]\+: *\)\=\zs.\{-\}\ze\%( (new commits)\)\=$')
if filename ==# ''
continue
endif
@@ -645,7 +697,7 @@ function! s:StagePatch(lnum1,lnum2) abort
silent! edit!
1
redraw
call search('^#\t\%([[:alpha:] ]\+: *\)\=\V'.first_filename.'\$','W')
call search('^#\t\%([[:alpha:] ]\+: *\)\=\V'.first_filename.'\%( (new commits)\)\=\$','W')
endif
catch /^fugitive:/
return 'echoerr v:errmsg'
@@ -667,16 +719,16 @@ function! s:Commit(args) abort
let errorfile = tempname()
try
execute cd.'`=s:repo().tree()`'
let command = ''
if &shell =~# 'cmd'
let command = ''
let old_editor = $GIT_EDITOR
let $GIT_EDITOR = 'false'
elseif &shell !~# 'csh'
let command = 'GIT_EDITOR=false '
else
let command = 'env GIT_EDITOR=false '
endif
let command .= s:repo().git_command('commit').' '.a:args
if &shell =~# 'csh'
silent execute '!setenv GIT_EDITOR false; ('.command.' > '.outfile.') >& '.errorfile
silent execute '!('.command.' > '.outfile.') >& '.errorfile
elseif a:args =~# '\%(^\| \)--interactive\>'
execute '!'.command.' 2> '.errorfile
else
@@ -690,8 +742,9 @@ function! s:Commit(args) abort
endif
return ''
else
let error = get(readfile(errorfile,'',1),0,'!')
if error =~# "'false'\\.$"
let errors = readfile(errorfile)
let error = get(errors,-2,get(errors,-1,'!'))
if error =~# '\<false''\=\.$'
let args = a:args
let args = s:gsub(args,'%(%(^| )-- )@<!%(^| )@<=%(-[se]|--edit|--interactive)%($| )','')
let args = s:gsub(args,'%(%(^| )-- )@<!%(^| )@<=%(-F|--file|-m|--message)%(\s+|\=)%(''[^'']*''|"%(\\.|[^"])*"|\\.|\S)*','')
@@ -700,13 +753,14 @@ function! s:Commit(args) abort
if args !~# '\%(^\| \)--cleanup\>'
let args = '--cleanup=strip '.args
endif
let old_nr = bufnr('')
if bufname('%') == '' && line('$') == 1 && getline(1) == '' && !&mod
edit `=msgfile`
else
split `=msgfile`
keepalt split `=msgfile`
endif
if old_type ==# 'index'
bdelete #
execute 'bdelete '.old_nr
endif
let b:fugitive_commit_arguments = args
setlocal bufhidden=delete filetype=gitcommit
@@ -741,7 +795,6 @@ endfunction
function! s:FinishCommit()
let args = getbufvar(+expand('<abuf>'),'fugitive_commit_arguments')
let g:args = args
if !empty(args)
call setbufvar(+expand('<abuf>'),'fugitive_commit_arguments','')
return s:Commit(args)
@@ -849,11 +902,8 @@ function! s:Edit(cmd,...) abort
catch /^fugitive:/
return 'echoerr v:errmsg'
endtry
if a:cmd =~# 'read!$' || a:cmd ==# 'read'
if a:cmd =~# '!$'
call s:warn(':Gread! is deprecated. Use :Gread')
endif
return 'silent %delete|read '.s:fnameescape(file).'|silent 1delete_|diffupdate|'.line('.')
if a:cmd ==# 'read'
return 'silent %delete_|read '.s:fnameescape(file).'|silent 1delete_|diffupdate|'.line('.')
else
if &previewwindow && getbufvar('','fugitive_type') ==# 'index'
wincmd p
@@ -875,9 +925,11 @@ call s:command("-bar -bang -nargs=? -complete=customlist,s:EditComplete Gtabedit
call s:command("-bar -bang -nargs=? -count -complete=customlist,s:EditComplete Gread :execute s:Edit((!<count> && <line1> ? '' : <count>).'read<bang>',<f-args>)")
" }}}1
" Gwrite {{{1
" Gwrite, Gwq {{{1
call s:command("-bar -bang -nargs=? -complete=customlist,s:EditComplete Gwrite :execute s:Write(<bang>0,<f-args>)")
call s:command("-bar -bang -nargs=? -complete=customlist,s:EditComplete Gw :execute s:Write(<bang>0,<f-args>)")
call s:command("-bar -bang -nargs=? -complete=customlist,s:EditComplete Gwq :execute s:Wq(<bang>0,<f-args>)")
function! s:Write(force,...) abort
if exists('b:fugitive_commit_arguments')
@@ -941,7 +993,11 @@ function! s:Write(force,...) abort
execute 'write! '.s:fnameescape(s:repo().translate(path))
endif
let error = s:repo().git_chomp_in_tree('add', file)
if a:force
let error = s:repo().git_chomp_in_tree('add', '--force', file)
else
let error = s:repo().git_chomp_in_tree('add', file)
endif
if v:shell_error
let v:errmsg = 'fugitive: '.error
return 'echoerr v:errmsg'
@@ -993,16 +1049,57 @@ function! s:Write(force,...) abort
return 'checktime'
endfunction
function! s:Wq(force,...) abort
let bang = a:force ? '!' : ''
if exists('b:fugitive_commit_arguments')
return 'wq'.bang
endif
let result = call(s:function('s:Write'),[a:force]+a:000)
if result =~# '^\%(write\|wq\|echoerr\)'
return s:sub(result,'^write','wq')
else
return result.'|quit'.bang
endif
endfunction
" }}}1
" Gdiff {{{1
call s:command("-bar -nargs=? -complete=customlist,s:EditComplete Gdiff :execute s:Diff(<f-args>)")
call s:command("-bang -bar -nargs=? -complete=customlist,s:EditComplete Gdiff :execute s:Diff(<bang>0,<f-args>)")
call s:command("-bar -nargs=? -complete=customlist,s:EditComplete Gvdiff :execute s:Diff(0,<f-args>)")
call s:command("-bar -nargs=? -complete=customlist,s:EditComplete Gsdiff :execute s:Diff(1,<f-args>)")
augroup fugitive_diff
autocmd BufWinLeave * if winnr('$') == 2 && &diff && getbufvar(+expand('<abuf>'), 'git_dir') !=# '' | diffoff! | endif
autocmd BufWinEnter * if winnr('$') == 1 && &diff && getbufvar(+expand('<abuf>'), 'git_dir') !=# '' | diffoff | endif
autocmd!
autocmd BufWinLeave * if s:diff_window_count() == 2 && &diff && getbufvar(+expand('<abuf>'), 'git_dir') !=# '' | call s:diff_off_all(getbufvar(+expand('<abuf>'), 'git_dir')) | endif
autocmd BufWinEnter * if s:diff_window_count() == 1 && &diff && getbufvar(+expand('<abuf>'), 'git_dir') !=# '' | diffoff | endif
augroup END
function! s:diff_window_count()
let c = 0
for nr in range(1,winnr('$'))
let c += getwinvar(nr,'&diff')
endfor
return c
endfunction
function! s:diff_off_all(dir)
for nr in range(1,winnr('$'))
if getwinvar(nr,'&diff')
if nr != winnr()
execute nr.'wincmd w'
let restorewinnr = 1
endif
if exists('b:git_dir') && b:git_dir ==# a:dir
diffoff
endif
if exists('restorewinnr')
wincmd p
endif
endif
endfor
endfunction
function! s:buffer_compare_age(commit) dict abort
let scores = {':0': 1, ':1': 2, ':2': 3, ':': 4, ':3': 5}
let my_score = get(scores,':'.self.commit(),0)
@@ -1025,18 +1122,22 @@ endfunction
call s:add_methods('buffer',['compare_age'])
function! s:Diff(...) abort
function! s:Diff(bang,...) abort
let split = a:bang ? 'split' : 'vsplit'
if exists(':DiffGitCached')
return 'DiffGitCached'
elseif (!a:0 || a:1 == ':') && s:buffer().commit() =~# '^[0-1]\=$' && s:repo().git_chomp_in_tree('ls-files', '--unmerged', '--', s:buffer().path()) !=# ''
leftabove vsplit `=fugitive#buffer().repo().translate(s:buffer().expand(':2'))`
diffthis
wincmd p
rightbelow vsplit `=fugitive#buffer().repo().translate(s:buffer().expand(':3'))`
diffthis
wincmd p
diffthis
return ''
let nr = bufnr('')
execute 'leftabove '.split.' `=fugitive#buffer().repo().translate(s:buffer().expand('':2''))`'
execute 'nnoremap <buffer> <silent> dp :diffput '.nr.'<Bar>diffupdate<CR>'
diffthis
wincmd p
execute 'rightbelow '.split.' `=fugitive#buffer().repo().translate(s:buffer().expand('':3''))`'
execute 'nnoremap <buffer> <silent> dp :diffput '.nr.'<Bar>diffupdate<CR>'
diffthis
wincmd p
diffthis
return ''
elseif a:0
if a:1 ==# ''
return ''
@@ -1044,7 +1145,7 @@ function! s:Diff(...) abort
let file = s:buffer().path('/')
elseif a:1 ==# ':'
let file = s:buffer().path(':0:')
elseif a:1 =~# '^:/'
elseif a:1 =~# '^:/.'
try
let file = s:repo().rev_parse(a:1).s:buffer().path(':')
catch /^fugitive:/
@@ -1063,9 +1164,9 @@ function! s:Diff(...) abort
let spec = s:repo().translate(file)
let commit = matchstr(spec,'\C[^:/]//\zs\x\+')
if s:buffer().compare_age(commit) < 0
rightbelow vsplit `=spec`
execute 'rightbelow '.split.' `=spec`'
else
leftabove vsplit `=spec`
execute 'leftabove '.split.' `=spec`'
endif
diffthis
wincmd p
@@ -1088,6 +1189,10 @@ function! s:Move(force,destination)
let destination = destination[strlen(s:repo().tree('')):-1]
endif
endif
if isdirectory(s:buffer().name())
" Work around Vim parser idiosyncrasy
let discarded = s:buffer().setvar('&swapfile',0)
endif
let message = call(s:repo().git_chomp_in_tree,['mv']+(a:force ? ['-f'] : [])+['--', s:buffer().path(), destination], s:repo())
if v:shell_error
let v:errmsg = 'fugitive: '.message
@@ -1099,7 +1204,11 @@ function! s:Move(force,destination)
endif
call fugitive#reload_status()
if s:buffer().commit() == ''
return 'saveas! '.s:fnameescape(destination)
if isdirectory(destination)
return 'edit '.s:fnameescape(destination)
else
return 'saveas! '.s:fnameescape(destination)
endif
else
return 'file '.s:fnameescape(s:repo().translate(':0:'.destination)
endif
@@ -1184,17 +1293,25 @@ function! s:Blame(bang,line1,line2,count,args) abort
else
let error = tempname()
let temp = error.'.fugitiveblame'
silent! exe '%write !'.basecmd.' > '.temp.' 2> '.error
if &shell =~# 'csh'
silent! execute '%write !('.basecmd.' > '.temp.') >& '.error
else
silent! execute '%write !'.basecmd.' > '.temp.' 2> '.error
endif
if exists('l:dir')
execute cd.'`=dir`'
unlet dir
endif
if v:shell_error
call s:throw(join(readfile(error),"\n"))
endif
let bufnr = bufnr('')
let restore = 'call setbufvar('.bufnr.',"&scrollbind",0)'
let restore = 'call setwinvar(bufwinnr('.bufnr.'),"&scrollbind",0)'
if &l:wrap
let restore .= '|call setbufvar('.bufnr.',"&wrap",1)'
let restore .= '|call setwinvar(bufwinnr('.bufnr.'),"&wrap",1)'
endif
if &l:foldenable
let restore .= '|call setbufvar('.bufnr.',"&foldenable",1)'
let restore .= '|call setwinvar(bufwinnr('.bufnr.'),"&foldenable",1)'
endif
let winnr = winnr()
windo set noscrollbind
@@ -1206,7 +1323,7 @@ function! s:Blame(bang,line1,line2,count,args) abort
let b:git_dir = git_dir
let b:fugitive_type = 'blame'
let b:fugitive_blamed_bufnr = bufnr
let b:fugitive_restore = restore
let w:fugitive_restore = restore
let b:fugitive_blame_arguments = join(a:args,' ')
call s:Detect(expand('%:p'))
execute top
@@ -1292,6 +1409,200 @@ function! s:BlameSyntax() abort
hi def link FugitiveblameNotCommittedYet Comment
endfunction
" }}}1
" Gbrowse {{{1
call s:command("-bar -bang -count=0 -nargs=? -complete=customlist,s:EditComplete Gbrowse :execute s:Browse(<bang>0,<line1>,<count>,<f-args>)")
function! s:Browse(bang,line1,count,...) abort
try
let rev = a:0 ? substitute(a:1,'@[[:alnum:]_-]*\%(://.\{-\}\)\=$','','') : ''
if rev ==# ''
let expanded = s:buffer().rev()
elseif rev ==# ':'
let expanded = s:buffer().path('/')
else
let expanded = s:buffer().expand(rev)
endif
let full = s:repo().translate(expanded)
let commit = ''
if full =~# '^fugitive://'
let commit = matchstr(full,'://.*//\zs\w\+')
let path = matchstr(full,'://.*//\w\+\zs/.*')
if commit =~ '..'
let type = s:repo().git_chomp('cat-file','-t',commit.s:sub(path,'^/',':'))
else
let type = 'blob'
endif
let path = path[1:-1]
elseif s:repo().bare()
let path = '.git/' . full[strlen(s:repo().dir())+1:-1]
let type = ''
else
let path = full[strlen(s:repo().tree())+1:-1]
if path =~# '^\.git/'
let type = ''
elseif isdirectory(full)
let type = 'tree'
else
let type = 'blob'
endif
endif
if path =~# '^\.git/.*HEAD' && filereadable(s:repo().dir(path[5:-1]))
let body = readfile(s:repo().dir(path[5:-1]))[0]
if body =~# '^\x\{40\}$'
let commit = body
let type = 'commit'
let path = ''
elseif body =~# '^ref: refs/'
let path = '.git/' . matchstr(body,'ref: \zs.*')
endif
endif
if a:0 && a:1 =~# '@[[:alnum:]_-]*\%(://.\{-\}\)\=$'
let remote = matchstr(a:1,'@\zs[[:alnum:]_-]\+\%(://.\{-\}\)\=$')
elseif path =~# '^\.git/refs/remotes/.'
let remote = matchstr(path,'^\.git/refs/remotes/\zs[^/]\+')
else
let remote = 'origin'
let branch = matchstr(rev,'^[[:alnum:]/._-]\+\ze[:^~@]')
if branch ==# '' && path =~# '^\.git/refs/\w\+/'
let branch = s:sub(path,'^\.git/refs/\w+/','')
endif
if filereadable(s:repo().dir('refs/remotes/'.branch))
let remote = matchstr(branch,'[^/]\+')
let rev = rev[strlen(remote)+1:-1]
else
if branch ==# ''
let branch = matchstr(s:repo().head_ref(),'\<refs/heads/\zs.*')
endif
if branch != ''
let remote = s:repo().git_chomp('config','branch.'.branch.'.remote')
if remote ==# ''
let remote = 'origin'
elseif rev[0:strlen(branch)-1] ==# branch && rev[strlen(branch)] =~# '[:^~@]'
let rev = s:repo().git_chomp('config','branch.'.branch.'.merge')[11:-1] . rev[strlen(branch):-1]
endif
endif
endif
endif
let raw = s:repo().git_chomp('config','remote.'.remote.'.url')
if raw ==# ''
let raw = remote
endif
let url = s:github_url(s:repo(),raw,rev,commit,path,type,a:line1,a:count)
if url == ''
let url = s:instaweb_url(s:repo(),rev,commit,path,type,a:count ? a:line1 : 0)
endif
if url == ''
call s:throw("Instaweb failed to start and '".remote."' is not a GitHub remote")
endif
if a:bang
let @* = url
return 'echomsg '.string(url)
else
return 'echomsg '.string(url).'|silent Git web--browse '.shellescape(url,1)
endif
catch /^fugitive:/
return 'echoerr v:errmsg'
endtry
endfunction
function! s:github_url(repo,url,rev,commit,path,type,line1,line2) abort
let path = a:path
let repo_path = matchstr(a:url,'^\%(https\=://\|git://\|git@\)github\.com[/:]\zs.\{-\}\ze\%(\.git\)\=$')
if repo_path ==# ''
return ''
endif
let root = 'https://github.com/' . repo_path
if path =~# '^\.git/refs/heads/'
let branch = a:repo.git_chomp('config','branch.'.path[16:-1].'.merge')[11:-1]
if branch ==# ''
return root . '/commits/' . path[16:-1]
else
return root . '/commits/' . branch
endif
elseif path =~# '^\.git/refs/.'
return root . '/commits/' . matchstr(path,'[^/]\+$')
elseif path =~# '.git/\%(config$\|hooks\>\)'
return root . '/admin'
elseif path =~# '^\.git\>'
return root
endif
if a:rev =~# '^[[:alnum:]._-]\+:'
let commit = matchstr(a:rev,'^[^:]*')
elseif a:commit =~# '^\d\=$'
let local = matchstr(a:repo.head_ref(),'\<refs/heads/\zs.*')
let commit = a:repo.git_chomp('config','branch.'.local.'.merge')[11:-1]
if commit ==# ''
let commit = local
endif
else
let commit = a:commit
endif
if a:type == 'tree'
let url = s:sub(root . '/tree/' . commit . '/' . path,'/$','')
elseif a:type == 'blob'
let url = root . '/blob/' . commit . '/' . path
if a:line2 && a:line1 == a:line2
let url .= '#L' . a:line1
elseif a:line2
let url .= '#L' . a:line1 . '-' . a:line2
endif
elseif a:type == 'tag'
let commit = matchstr(getline(3),'^tag \zs.*')
let url = root . '/tree/' . commit
else
let url = root . '/commit/' . commit
endif
return url
endfunction
function! s:instaweb_url(repo,rev,commit,path,type,...) abort
let output = a:repo.git_chomp('instaweb','-b','unknown')
if output =~# 'http://'
let root = matchstr(output,'http://.*').'/?p='.fnamemodify(a:repo.dir(),':t')
else
return ''
endif
if a:path =~# '^\.git/refs/.'
return root . ';a=shortlog;h=' . matchstr(a:path,'^\.git/\zs.*')
elseif a:path =~# '^\.git\>'
return root
endif
let url = root
if a:commit =~# '^\x\{40\}$'
if a:type ==# 'commit'
let url .= ';a=commit'
endif
let url .= ';h=' . a:repo.rev_parse(a:commit . (a:path == '' ? '' : ':' . a:path))
else
if a:type ==# 'blob'
let tmp = tempname()
silent execute 'write !'.a:repo.git_command('hash-object','-w','--stdin').' > '.tmp
let url .= ';h=' . readfile(tmp)[0]
else
try
let url .= ';h=' . a:repo.rev_parse((a:commit == '' ? 'HEAD' : ':' . a:commit) . ':' . a:path)
catch /^fugitive:/
call s:throw('fugitive: cannot browse uncommitted file')
endtry
endif
let root .= ';hb=' . matchstr(a:repo.head_ref(),'[^ ]\+$')
endif
if a:path !=# ''
let url .= ';f=' . a:path
endif
if a:0 && a:1
let url .= '#l' . a:1
endif
return url
endfunction
" }}}1
" File access {{{1
@@ -1305,10 +1616,8 @@ function! s:ReplaceCmd(cmd,...) abort
if &shell =~# 'cmd'
let old_index = $GIT_INDEX_FILE
let $GIT_INDEX_FILE = a:1
elseif &shell =~# 'csh'
let prefix = 'setenv GIT_INDEX_FILE '.s:shellesc(a:1).'; '
else
let prefix = 'GIT_INDEX_FILE='.s:shellesc(a:1).' '
let prefix = 'env GIT_INDEX_FILE='.s:shellesc(a:1).' '
endif
endif
set noautowrite
@@ -1338,7 +1647,7 @@ function! s:BufReadIndex()
if fnamemodify($GIT_INDEX_FILE !=# '' ? $GIT_INDEX_FILE : b:git_dir . '/index', ':p') ==# expand('%:p')
let index = ''
else
let index = expand('%')
let index = expand('%:p')
endif
if b:fugitive_display_format
call s:ReplaceCmd(s:repo().git_command('ls-files','--stage'),index)
@@ -1358,10 +1667,16 @@ function! s:BufReadIndex()
nnoremap <buffer> <silent> a :<C-U>let b:fugitive_display_format += 1<Bar>exe <SID>BufReadIndex()<CR>
nnoremap <buffer> <silent> i :<C-U>let b:fugitive_display_format -= 1<Bar>exe <SID>BufReadIndex()<CR>
nnoremap <buffer> <silent> D :<C-U>execute <SID>StageDiff()<CR>
nnoremap <buffer> <silent> dd :<C-U>execute <SID>StageDiff()<CR>
nnoremap <buffer> <silent> dh :<C-U>execute <SID>StageDiff('Gsdiff')<CR>
nnoremap <buffer> <silent> ds :<C-U>execute <SID>StageDiff('Gsdiff')<CR>
nnoremap <buffer> <silent> dv :<C-U>execute <SID>StageDiff()<CR>
nnoremap <buffer> <silent> - :<C-U>execute <SID>StageToggle(line('.'),line('.')+v:count1-1)<CR>
xnoremap <buffer> <silent> - :<C-U>execute <SID>StageToggle(line("'<"),line("'>"))<CR>
nnoremap <buffer> <silent> p :<C-U>execute <SID>StagePatch(line('.'),line('.')+v:count1-1)<CR>
xnoremap <buffer> <silent> p :<C-U>execute <SID>StagePatch(line("'<"),line("'>"))<CR>
nnoremap <buffer> <silent> <C-N> :call search('^#\t.*','W')<Bar>.<CR>
nnoremap <buffer> <silent> <C-P> :call search('^#\t.*','Wbe')<Bar>.<CR>
call s:JumpInit()
nunmap <buffer> P
nunmap <buffer> ~
@@ -1415,7 +1730,11 @@ function! s:BufWriteIndexFile()
endif
let info = old_mode.' '.sha1.' '.stage."\t".path
call writefile([info],tmp)
let error = system(s:repo().git_command('update-index','--index-info').' < '.tmp)
if has('win32')
let error = system('type '.tmp.'|'.s:repo().git_command('update-index','--index-info'))
else
let error = system(s:repo().git_command('update-index','--index-info').' < '.tmp)
endif
if v:shell_error == 0
setlocal nomodified
silent execute 'doautocmd BufWritePost '.s:fnameescape(expand('%:p'))
@@ -1539,9 +1858,9 @@ function! s:GF(mode) abort
if showtree && line('.') == 1
return ""
elseif showtree && line('.') > 2
return s:Edit(a:mode,buffer.commit().':'.(buffer.path() == '' ? '' : buffer.path().'/').s:sub(getline('.'),'/$',''))
return s:Edit(a:mode,buffer.commit().':'.s:buffer().path().(buffer.path() =~# '^$\|/$' ? '' : '/').s:sub(getline('.'),'/$',''))
elseif getline('.') =~# '^\d\{6\} \l\{3,8\} \x\{40\}\t'
return s:Edit(a:mode,buffer.commit().':'.(buffer.path() == '' ? '' : buffer.path().'/').s:sub(matchstr(getline('.'),'\t\zs.*'),'/$',''))
return s:Edit(a:mode,buffer.commit().':'.s:buffer().path().(buffer.path() =~# '^$\|/$' ? '' : '/').s:sub(matchstr(getline('.'),'\t\zs.*'),'/$',''))
endif
elseif buffer.type('blob')
@@ -1566,7 +1885,7 @@ function! s:GF(mode) abort
let file = '/'.matchstr(getline('.'),' -> \zs.*')
return s:Edit(a:mode,file)
elseif getline('.') =~# '^#\t[[:alpha:] ]\+: *.'
let file = '/'.matchstr(getline('.'),': *\zs.*')
let file = '/'.matchstr(getline('.'),': *\zs.\{-\}\ze\%( (new commits)\)\=$')
return s:Edit(a:mode,file)
elseif getline('.') =~# '^#\t.'
let file = '/'.matchstr(getline('.'),'#\t\zs.*')
@@ -1629,6 +1948,13 @@ function! s:GF(mode) abort
elseif getline('.') =~# '^diff --git \%(a/.*\|/dev/null\) \%(b/.*\|/dev/null\)'
let dref = matchstr(getline('.'),'\Cdiff --git \zs\%(a/.*\|/dev/null\)\ze \%(b/.*\|/dev/null\)')
let ref = matchstr(getline('.'),'\Cdiff --git \%(a/.*\|/dev/null\) \zs\%(b/.*\|/dev/null\)')
let dcmd = 'Gdiff'
elseif getline('.') =~# '^index ' && getline(line('.')-1) =~# '^diff --git \%(a/.*\|/dev/null\) \%(b/.*\|/dev/null\)'
let line = getline(line('.')-1)
let dref = matchstr(line,'\Cdiff --git \zs\%(a/.*\|/dev/null\)\ze \%(b/.*\|/dev/null\)')
let ref = matchstr(line,'\Cdiff --git \%(a/.*\|/dev/null\) \zs\%(b/.*\|/dev/null\)')
let dcmd = 'Gdiff!'
elseif line('$') == 1 && getline('.') =~ '^\x\{40\}$'
let ref = getline('.')
@@ -1656,7 +1982,7 @@ function! s:GF(mode) abort
endif
if exists('dref')
return s:Edit(a:mode,ref) . '|Gdiff '.s:fnameescape(dref)
return s:Edit(a:mode,ref) . '|'.dcmd.' '.s:fnameescape(dref)
elseif ref != ""
return s:Edit(a:mode,ref)
endif
@@ -1698,6 +2024,18 @@ function! fugitive#statusline(...)
endif
endfunction
function! s:repo_config(conf) dict abort
return matchstr(system(s:repo().git_command('config').' '.a:conf),"[^\r\n]*")
endfun
function! s:repo_user() dict abort
let username = s:repo().config('user.name')
let useremail = s:repo().config('user.email')
return username.' <'.useremail.'>'
endfun
call s:add_methods('repo',['config', 'user'])
" }}}1
" vim:set ft=vim ts=8 sw=2 sts=2: