Lay groundwork for running commands without Git dir
This commit is contained in:
parent
00bced7c53
commit
aa41caf6c7
@ -68,11 +68,11 @@ function! s:throw(string) abort
|
|||||||
throw 'fugitive: '.a:string
|
throw 'fugitive: '.a:string
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:warn(str) abort
|
function! s:DirCheck(...) abort
|
||||||
echohl WarningMsg
|
if empty(a:0 ? s:Dir(a:1) : s:Dir())
|
||||||
echomsg a:str
|
return 'return ' . string('echoerr "fugitive: not a Git repository"')
|
||||||
echohl None
|
endif
|
||||||
let v:warningmsg = a:str
|
return ''
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:Mods(mods, ...) abort
|
function! s:Mods(mods, ...) abort
|
||||||
@ -1922,8 +1922,6 @@ endif
|
|||||||
function! s:SetupTemp(file) abort
|
function! s:SetupTemp(file) abort
|
||||||
if has_key(s:temp_files, s:cpath(a:file))
|
if has_key(s:temp_files, s:cpath(a:file))
|
||||||
let dict = s:temp_files[s:cpath(a:file)]
|
let dict = s:temp_files[s:cpath(a:file)]
|
||||||
let b:git_dir = dict.dir
|
|
||||||
call extend(b:, {'fugitive_type': 'temp'}, 'keep')
|
|
||||||
if has_key(dict, 'filetype') && dict.filetype !=# &l:filetype
|
if has_key(dict, 'filetype') && dict.filetype !=# &l:filetype
|
||||||
let &l:filetype = dict.filetype
|
let &l:filetype = dict.filetype
|
||||||
endif
|
endif
|
||||||
@ -1934,9 +1932,13 @@ function! s:SetupTemp(file) abort
|
|||||||
if getline(1) !~# '^diff '
|
if getline(1) !~# '^diff '
|
||||||
setlocal nomodifiable
|
setlocal nomodifiable
|
||||||
endif
|
endif
|
||||||
call FugitiveDetect(a:file)
|
if len(dict.dir)
|
||||||
if &filetype ==# 'git'
|
let b:git_dir = dict.dir
|
||||||
call fugitive#MapJumps()
|
call extend(b:, {'fugitive_type': 'temp'}, 'keep')
|
||||||
|
call FugitiveDetect(a:file)
|
||||||
|
if &filetype ==# 'git'
|
||||||
|
call fugitive#MapJumps()
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
return ''
|
return ''
|
||||||
@ -2026,16 +2028,18 @@ call s:command("-bar -bang -nargs=? -complete=customlist,s:DirComplete Glcd :exe
|
|||||||
call s:command("-bar -bang -range=-1 Gstatus", "Status")
|
call s:command("-bar -bang -range=-1 Gstatus", "Status")
|
||||||
call s:command("-bar -bang -range=-1 G", "Status")
|
call s:command("-bar -bang -range=-1 G", "Status")
|
||||||
|
|
||||||
function! s:StatusCommand(line1, line2, range, count, bang, mods, reg, arg, args) abort
|
function! s:StatusCommand(line1, line2, range, count, bang, mods, reg, arg, args, ...) abort
|
||||||
|
let dir = a:0 ? a:1 : s:Dir()
|
||||||
|
exe s:DirCheck(dir)
|
||||||
try
|
try
|
||||||
let mods = s:Mods(a:mods, &splitbelow ? 'botright' : 'topleft')
|
let mods = s:Mods(a:mods, &splitbelow ? 'botright' : 'topleft')
|
||||||
let file = fugitive#Find(':')
|
let file = fugitive#Find(':', dir)
|
||||||
let arg = ' +setl\ foldmethod=syntax\ foldlevel=1\|let\ w:fugitive_status=FugitiveGitDir() ' .
|
let arg = ' +setl\ foldmethod=syntax\ foldlevel=1\|let\ w:fugitive_status=FugitiveGitDir() ' .
|
||||||
\ s:fnameescape(file)
|
\ s:fnameescape(file)
|
||||||
for winnr in range(1, winnr('$'))
|
for winnr in range(1, winnr('$'))
|
||||||
if s:cpath(file, fnamemodify(bufname(winbufnr(winnr)), ':p'))
|
if s:cpath(file, fnamemodify(bufname(winbufnr(winnr)), ':p'))
|
||||||
exe winnr . 'wincmd w'
|
exe winnr . 'wincmd w'
|
||||||
let w:fugitive_status = FugitiveGitDir()
|
let w:fugitive_status = dir
|
||||||
return s:ReloadStatus()
|
return s:ReloadStatus()
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
|
Loading…
x
Reference in New Issue
Block a user