motiejus/dotfiles

Unnamed repository; edit this file 'description' to name the repository.
git clone https://git.jakstys.lt/motiejus/dotfiles.git
Log | Tree | Refs | README | LICENSE

commit cff78c3ab4605d490e6be8d8af02f1e7efd25c95 (tree)
parent 41383131b861c12abd82ad55a9546b9b715925a0
Author: Trent Ogren <tedwardo2@gmail.com>
Date:   Fri, 21 Sep 2012 11:30:28 -0500

Pick sane git_dir for :Gedit from :Gstatus window

When using a :Gedit command from the :Gstatus window the git_dir was
being based on the window that was switched into in order to edit the
file. So if Fugitive switched into a window with a file from a different
Git repo (or a file with no Git repo) the :Gedit command could fail or
edit the wrong file.

Instead base the git_dir on the window from which the :Gedit command
originated.

Diffstat:
Mplugin/fugitive.vim | 15++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim @@ -1072,6 +1072,7 @@ endfunction " Gedit, Gpedit, Gsplit, Gvsplit, Gtabedit, Gread {{{1 function! s:Edit(cmd,bang,...) abort + let buffer = s:buffer() if a:cmd !~# 'read' if &previewwindow && getbufvar('','fugitive_type') ==# 'index' wincmd p @@ -1091,7 +1092,7 @@ function! s:Edit(cmd,bang,...) abort if a:bang let args = s:gsub(a:0 ? a:1 : '', '\\@<!%(\\\\)*\zs[%#]', '\=s:buffer().expand(submatch(0))') if a:cmd =~# 'read' - let git = s:repo().git_command() + let git = buffer.repo().git_command() let last = line('$') silent call s:ExecuteInTree((a:cmd ==# 'read' ? '$read' : a:cmd).'!'.git.' --no-pager '.args) if a:cmd ==# 'read' @@ -1102,7 +1103,7 @@ function! s:Edit(cmd,bang,...) abort return 'redraw|echo '.string(':!'.git.' '.args) else let temp = resolve(tempname()) - let s:temp_files[temp] = s:repo().dir() + let s:temp_files[temp] = buffer.repo().dir() silent execute a:cmd.' '.temp if a:cmd =~# 'pedit' wincmd P @@ -1124,16 +1125,16 @@ function! s:Edit(cmd,bang,...) abort if a:0 && a:1 == '' return '' elseif a:0 - let file = s:buffer().expand(a:1) + let file = buffer.expand(a:1) elseif expand('%') ==# '' let file = ':' - elseif s:buffer().commit() ==# '' && s:buffer().path('/') !~# '^/.git\>' - let file = s:buffer().path(':') + elseif buffer.commit() ==# '' && buffer.path('/') !~# '^/.git\>' + let file = buffer.path(':') else - let file = s:buffer().path('/') + let file = buffer.path('/') endif try - let file = s:repo().translate(file) + let file = buffer.repo().translate(file) catch /^fugitive:/ return 'echoerr v:errmsg' endtry