Eliminate remaining s:repo().dir() and s:repo().tree() calls
This commit is contained in:
parent
4f82d241cc
commit
f8fb5eafab
@ -119,9 +119,13 @@ function! fugitive#GitVersion(...) abort
|
|||||||
return s:git_versions[g:fugitive_git_executable]
|
return s:git_versions[g:fugitive_git_executable]
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! s:Tree(...) abort
|
||||||
|
return FugitiveTreeForGitDir(a:0 ? a:1 : get(b:, 'git_dir', ''))
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! s:TreeChomp(...) abort
|
function! s:TreeChomp(...) abort
|
||||||
let args = copy(a:000)
|
let args = copy(a:000)
|
||||||
let tree = FugitiveTreeForGitDir(b:git_dir)
|
let tree = s:Tree()
|
||||||
let pre = ''
|
let pre = ''
|
||||||
if empty(tree)
|
if empty(tree)
|
||||||
let args = ['--git-dir=' . b:git_dir] . args
|
let args = ['--git-dir=' . b:git_dir] . args
|
||||||
@ -305,7 +309,7 @@ function! s:repo_dir(...) dict abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:repo_tree(...) dict abort
|
function! s:repo_tree(...) dict abort
|
||||||
let dir = FugitiveTreeForGitDir(self.git_dir)
|
let dir = s:Tree(self.git_dir)
|
||||||
if dir ==# ''
|
if dir ==# ''
|
||||||
call s:throw('no work tree')
|
call s:throw('no work tree')
|
||||||
else
|
else
|
||||||
@ -317,14 +321,14 @@ function! s:repo_bare() dict abort
|
|||||||
if self.dir() =~# '/\.git$'
|
if self.dir() =~# '/\.git$'
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
return FugitiveTreeForGitDir(self.git_dir) ==# ''
|
return s:Tree(self.git_dir) ==# ''
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:repo_translate(spec, ...) dict abort
|
function! s:repo_translate(spec, ...) dict abort
|
||||||
let rev = a:spec
|
let rev = a:spec
|
||||||
let dir = self.git_dir
|
let dir = self.git_dir
|
||||||
let tree = FugitiveTreeForGitDir(dir)
|
let tree = s:Tree(dir)
|
||||||
if rev ==# '.'
|
if rev ==# '.'
|
||||||
let f = empty(tree) ? dir : tree
|
let f = empty(tree) ? dir : tree
|
||||||
elseif rev =~# '^/\=\.git$' && empty(tree)
|
elseif rev =~# '^/\=\.git$' && empty(tree)
|
||||||
@ -504,7 +508,7 @@ endfunction
|
|||||||
function! fugitive#Real(url) abort
|
function! fugitive#Real(url) abort
|
||||||
let [dir, commit, file] = s:DirCommitFile(a:url)
|
let [dir, commit, file] = s:DirCommitFile(a:url)
|
||||||
if len(dir)
|
if len(dir)
|
||||||
let tree = FugitiveTreeForGitDir(dir)
|
let tree = s:Tree(dir)
|
||||||
return s:PlatformSlash((len(tree) ? tree : dir) . file)
|
return s:PlatformSlash((len(tree) ? tree : dir) . file)
|
||||||
endif
|
endif
|
||||||
let url = len(url) ? fnamemodify(a:url, ':p' . (a:url =~# '[\/]$' ? '' : ':s?[\/]$??')) : ''
|
let url = len(url) ? fnamemodify(a:url, ':p' . (a:url =~# '[\/]$' ? '' : ':s?[\/]$??')) : ''
|
||||||
@ -520,7 +524,7 @@ function! fugitive#Path(url, ...) abort
|
|||||||
endif
|
endif
|
||||||
let url = s:shellslash(fnamemodify(a:url, ':p'))
|
let url = s:shellslash(fnamemodify(a:url, ':p'))
|
||||||
let dir = a:0 > 1 ? a:2 : get(b:, 'git_dir', '')
|
let dir = a:0 > 1 ? a:2 : get(b:, 'git_dir', '')
|
||||||
let tree = FugitiveTreeForGitDir(dir)
|
let tree = s:Tree(dir)
|
||||||
let [argdir, commit, file] = s:DirCommitFile(a:url)
|
let [argdir, commit, file] = s:DirCommitFile(a:url)
|
||||||
if len(argdir) && s:cpath(argdir) !=# s:cpath(dir)
|
if len(argdir) && s:cpath(argdir) !=# s:cpath(dir)
|
||||||
let file = ''
|
let file = ''
|
||||||
@ -605,7 +609,7 @@ function! fugitive#simplify(url) abort
|
|||||||
return ''
|
return ''
|
||||||
endif
|
endif
|
||||||
if file =~# '/\.\.\%(/\|$\)'
|
if file =~# '/\.\.\%(/\|$\)'
|
||||||
let tree = FugitiveTreeForGitDir(dir)
|
let tree = s:Tree(dir)
|
||||||
if len(tree)
|
if len(tree)
|
||||||
let path = simplify(tree . file)
|
let path = simplify(tree . file)
|
||||||
if strpart(path . '/', 0, len(tree) + 1) !=# tree . '/'
|
if strpart(path . '/', 0, len(tree) + 1) !=# tree . '/'
|
||||||
@ -978,7 +982,7 @@ function! s:Git(bang, mods, args) abort
|
|||||||
endif
|
endif
|
||||||
let args = matchstr(a:args,'\v\C.{-}%($|\\@<!%(\\\\)*\|)@=')
|
let args = matchstr(a:args,'\v\C.{-}%($|\\@<!%(\\\\)*\|)@=')
|
||||||
let after = matchstr(a:args, '\v\C\\@<!%(\\\\)*\zs\|.*')
|
let after = matchstr(a:args, '\v\C\\@<!%(\\\\)*\zs\|.*')
|
||||||
let tree = s:repo().tree()
|
let tree = s:Tree()
|
||||||
if has('win32')
|
if has('win32')
|
||||||
let after = '|call fugitive#ReloadStatus()' . after
|
let after = '|call fugitive#ReloadStatus()' . after
|
||||||
endif
|
endif
|
||||||
@ -1034,13 +1038,13 @@ endfunction
|
|||||||
|
|
||||||
function! s:DirComplete(A, L, P) abort
|
function! s:DirComplete(A, L, P) abort
|
||||||
let base = s:sub(a:A,'^/','')
|
let base = s:sub(a:A,'^/','')
|
||||||
let matches = split(glob(s:repo().tree(s:gsub(base,'/','*&').'*/')),"\n")
|
let matches = split(glob(s:Tree() . '/' . s:gsub(base,'/','*&').'*/'),"\n")
|
||||||
call map(matches,'v:val[ strlen(s:repo().tree())+(a:A !~ "^/") : -1 ]')
|
call map(matches,'v:val[ strlen(s:Tree())+(a:A !~ "^/") : -1 ]')
|
||||||
return matches
|
return matches
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
call s:command("-bar -bang -nargs=? -complete=customlist,s:DirComplete Gcd :exe 'cd<bang>' s:fnameescape(s:repo().bare() ? s:repo().dir(<q-args>) : s:repo().tree(<q-args>))")
|
call s:command("-bar -bang -nargs=? -complete=customlist,s:DirComplete Gcd :exe 'cd<bang>' s:fnameescape((empty(s:Tree()) ? b:git_dir : s:Tree()) . '/' . <q-args>")
|
||||||
call s:command("-bar -bang -nargs=? -complete=customlist,s:DirComplete Glcd :exe 'lcd<bang>' s:fnameescape(s:repo().bare() ? s:repo().dir(<q-args>) : s:repo().tree(<q-args>))")
|
call s:command("-bar -bang -nargs=? -complete=customlist,s:DirComplete Glcd :exe 'lcd<bang>' s:fnameescape((empty(s:Tree()) ? b:git_dir : s:Tree()) . '/' . <q-args>")
|
||||||
|
|
||||||
" Section: Gstatus
|
" Section: Gstatus
|
||||||
|
|
||||||
@ -1137,7 +1141,7 @@ endfunction
|
|||||||
|
|
||||||
function! s:StagePrevious(count) abort
|
function! s:StagePrevious(count) abort
|
||||||
if line('.') == 1 && exists(':CtrlP') && get(g:, 'ctrl_p_map') =~? '^<c-p>$'
|
if line('.') == 1 && exists(':CtrlP') && get(g:, 'ctrl_p_map') =~? '^<c-p>$'
|
||||||
return 'CtrlP '.fnameescape(s:repo().tree())
|
return 'CtrlP '.fnameescape(s:Tree())
|
||||||
else
|
else
|
||||||
for i in range(a:count)
|
for i in range(a:count)
|
||||||
call search('^.\=\t.*','Wbe')
|
call search('^.\=\t.*','Wbe')
|
||||||
@ -1342,7 +1346,7 @@ call s:command("-nargs=? -complete=customlist,s:CommitComplete Gcommit :execute
|
|||||||
function! s:Commit(mods, args, ...) abort
|
function! s:Commit(mods, args, ...) abort
|
||||||
let mods = s:gsub(a:mods ==# '<mods>' ? '' : a:mods, '<tab>', '-tab')
|
let mods = s:gsub(a:mods ==# '<mods>' ? '' : a:mods, '<tab>', '-tab')
|
||||||
let dir = a:0 ? a:1 : b:git_dir
|
let dir = a:0 ? a:1 : b:git_dir
|
||||||
let tree = FugitiveTreeForGitDir(dir)
|
let tree = s:Tree(dir)
|
||||||
let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd' : 'cd'
|
let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd' : 'cd'
|
||||||
let cwd = getcwd()
|
let cwd = getcwd()
|
||||||
let msgfile = dir . '/COMMIT_EDITMSG'
|
let msgfile = dir . '/COMMIT_EDITMSG'
|
||||||
@ -1507,7 +1511,7 @@ function! s:Merge(cmd, bang, args) abort
|
|||||||
let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd' : 'cd'
|
let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd' : 'cd'
|
||||||
let cwd = getcwd()
|
let cwd = getcwd()
|
||||||
let [mp, efm] = [&l:mp, &l:efm]
|
let [mp, efm] = [&l:mp, &l:efm]
|
||||||
let had_merge_msg = filereadable(s:repo().dir('MERGE_MSG'))
|
let had_merge_msg = filereadable(b:git_dir . '/MERGE_MSG')
|
||||||
try
|
try
|
||||||
let &l:errorformat = ''
|
let &l:errorformat = ''
|
||||||
\ . '%-Gerror:%.%#false''.,'
|
\ . '%-Gerror:%.%#false''.,'
|
||||||
@ -1530,7 +1534,7 @@ function! s:Merge(cmd, bang, args) abort
|
|||||||
\ . "%+E\u51b2\u7a81 %.%#,"
|
\ . "%+E\u51b2\u7a81 %.%#,"
|
||||||
\ . 'U%\t%f'
|
\ . 'U%\t%f'
|
||||||
if a:cmd =~# '^merge' && empty(a:args) &&
|
if a:cmd =~# '^merge' && empty(a:args) &&
|
||||||
\ (had_merge_msg || isdirectory(s:repo().dir('rebase-apply')) ||
|
\ (had_merge_msg || isdirectory(b:git_dir . '/rebase-apply') ||
|
||||||
\ !empty(s:TreeChomp('diff-files', '--diff-filter=U')))
|
\ !empty(s:TreeChomp('diff-files', '--diff-filter=U')))
|
||||||
let &l:makeprg = g:fugitive_git_executable.' diff-files --name-status --diff-filter=U'
|
let &l:makeprg = g:fugitive_git_executable.' diff-files --name-status --diff-filter=U'
|
||||||
else
|
else
|
||||||
@ -1544,7 +1548,7 @@ function! s:Merge(cmd, bang, args) abort
|
|||||||
else
|
else
|
||||||
let &l:makeprg = 'env GIT_EDITOR=false ' . &l:makeprg
|
let &l:makeprg = 'env GIT_EDITOR=false ' . &l:makeprg
|
||||||
endif
|
endif
|
||||||
execute cd fnameescape(s:repo().tree())
|
execute cd fnameescape(s:Tree())
|
||||||
silent noautocmd make!
|
silent noautocmd make!
|
||||||
catch /^Vim\%((\a\+)\)\=:E211/
|
catch /^Vim\%((\a\+)\)\=:E211/
|
||||||
let err = v:exception
|
let err = v:exception
|
||||||
@ -1558,9 +1562,9 @@ function! s:Merge(cmd, bang, args) abort
|
|||||||
endtry
|
endtry
|
||||||
call fugitive#ReloadStatus()
|
call fugitive#ReloadStatus()
|
||||||
if empty(filter(getqflist(),'v:val.valid'))
|
if empty(filter(getqflist(),'v:val.valid'))
|
||||||
if !had_merge_msg && filereadable(s:repo().dir('MERGE_MSG'))
|
if !had_merge_msg && filereadable(b:git_dir . '/MERGE_MSG')
|
||||||
cclose
|
cclose
|
||||||
return 'Gcommit --no-status -n -t '.s:shellesc(s:repo().dir('MERGE_MSG'))
|
return 'Gcommit --no-status -n -t '.s:shellesc(b:git_dir . '/MERGE_MSG')
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
let qflist = getqflist()
|
let qflist = getqflist()
|
||||||
@ -1598,7 +1602,7 @@ function! s:Grep(cmd,bang,arg) abort
|
|||||||
let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd' : 'cd'
|
let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd' : 'cd'
|
||||||
let dir = getcwd()
|
let dir = getcwd()
|
||||||
try
|
try
|
||||||
execute cd s:fnameescape(s:repo().tree())
|
execute cd s:fnameescape(s:Tree())
|
||||||
let &grepprg = s:UserCommand() . ' --no-pager grep -n --no-color'
|
let &grepprg = s:UserCommand() . ' --no-pager grep -n --no-color'
|
||||||
let &grepformat = '%f:%l:%m,%m %f match%ts,%f'
|
let &grepformat = '%f:%l:%m,%m %f match%ts,%f'
|
||||||
exe a:cmd.'! '.escape(matchstr(a:arg,'\v\C.{-}%($|[''" ]\@=\|)@='),'|')
|
exe a:cmd.'! '.escape(matchstr(a:arg,'\v\C.{-}%($|[''" ]\@=\|)@='),'|')
|
||||||
@ -1637,7 +1641,7 @@ function! s:Log(cmd, bang, line1, line2, ...) abort
|
|||||||
let path = ''
|
let path = ''
|
||||||
endif
|
endif
|
||||||
let cmd = ['--no-pager', 'log', '--no-color']
|
let cmd = ['--no-pager', 'log', '--no-color']
|
||||||
let cmd += ['--pretty=format:fugitive://'.s:repo().dir().'//%H'.path.'::'.g:fugitive_summary_format]
|
let cmd += ['--pretty=format:fugitive://'.b:git_dir.'//%H'.path.'::'.g:fugitive_summary_format]
|
||||||
if empty(filter(a:000[0 : index(a:000,'--')],'v:val !~# "^-"'))
|
if empty(filter(a:000[0 : index(a:000,'--')],'v:val !~# "^-"'))
|
||||||
let commit = s:DirCommitFile(@%)[1]
|
let commit = s:DirCommitFile(@%)[1]
|
||||||
if len(commit) > 2
|
if len(commit) > 2
|
||||||
@ -1659,7 +1663,7 @@ function! s:Log(cmd, bang, line1, line2, ...) abort
|
|||||||
let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd' : 'cd'
|
let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd' : 'cd'
|
||||||
let dir = getcwd()
|
let dir = getcwd()
|
||||||
try
|
try
|
||||||
execute cd s:fnameescape(s:repo().tree())
|
execute cd s:fnameescape(s:Tree())
|
||||||
let &grepprg = escape(s:UserCommand() . join(map(cmd, '" ".s:shellesc(v:val)'), ''), '%#')
|
let &grepprg = escape(s:UserCommand() . join(map(cmd, '" ".s:shellesc(v:val)'), ''), '%#')
|
||||||
let &grepformat = '%Cdiff %.%#,%C--- %.%#,%C+++ %.%#,%Z@@ -%\d%\+\,%\d%\+ +%l\,%\d%\+ @@,%-G-%.%#,%-G+%.%#,%-G %.%#,%A%f::%m,%-G%.%#'
|
let &grepformat = '%Cdiff %.%#,%C--- %.%#,%C+++ %.%#,%Z@@ -%\d%\+\,%\d%\+ +%l\,%\d%\+ @@,%-G-%.%#,%-G+%.%#,%-G %.%#,%A%f::%m,%-G%.%#'
|
||||||
exe a:cmd . (a:bang ? '!' : '')
|
exe a:cmd . (a:bang ? '!' : '')
|
||||||
@ -1763,7 +1767,7 @@ function! s:Read(count, line1, line2, range, bang, mods, args, ...) abort
|
|||||||
let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd' : 'cd'
|
let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd' : 'cd'
|
||||||
let cwd = getcwd()
|
let cwd = getcwd()
|
||||||
try
|
try
|
||||||
execute cd s:fnameescape(s:repo().tree())
|
execute cd s:fnameescape(s:Tree())
|
||||||
silent execute mods after.'read!' git '--no-pager' args
|
silent execute mods after.'read!' git '--no-pager' args
|
||||||
finally
|
finally
|
||||||
execute cd s:fnameescape(cwd)
|
execute cd s:fnameescape(cwd)
|
||||||
@ -1978,7 +1982,7 @@ function! s:Dispatch(bang, args)
|
|||||||
let b:current_compiler = 'git'
|
let b:current_compiler = 'git'
|
||||||
let &l:errorformat = s:common_efm
|
let &l:errorformat = s:common_efm
|
||||||
let &l:makeprg = substitute(s:UserCommand() . ' ' . a:args, '\s\+$', '', '')
|
let &l:makeprg = substitute(s:UserCommand() . ' ' . a:args, '\s\+$', '', '')
|
||||||
execute cd fnameescape(s:repo().tree())
|
execute cd fnameescape(s:Tree())
|
||||||
if exists(':Make') == 2
|
if exists(':Make') == 2
|
||||||
noautocmd Make
|
noautocmd Make
|
||||||
else
|
else
|
||||||
@ -2209,7 +2213,7 @@ function! s:Move(force, rename, destination) abort
|
|||||||
let v:errmsg = 'fugitive: '.message
|
let v:errmsg = 'fugitive: '.message
|
||||||
return 'echoerr v:errmsg'
|
return 'echoerr v:errmsg'
|
||||||
endif
|
endif
|
||||||
let destination = s:repo().tree(destination)
|
let destination = s:Tree() . '/' . destination
|
||||||
if isdirectory(destination)
|
if isdirectory(destination)
|
||||||
let destination = fnamemodify(s:sub(destination,'/$','').'/'.expand('%:t'),':.')
|
let destination = fnamemodify(s:sub(destination,'/$','').'/'.expand('%:t'),':.')
|
||||||
endif
|
endif
|
||||||
@ -2333,7 +2337,7 @@ function! s:Blame(bang, line1, line2, count, mods, args) abort
|
|||||||
let basecmd = escape(call('s:Prepare', cmd), '!#%')
|
let basecmd = escape(call('s:Prepare', cmd), '!#%')
|
||||||
try
|
try
|
||||||
let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd' : 'cd'
|
let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd' : 'cd'
|
||||||
let tree = FugitiveTreeForGitDir(b:git_dir)
|
let tree = s:Tree()
|
||||||
if len(tree) && s:cpath(tree) !=# s:cpath(getcwd())
|
if len(tree) && s:cpath(tree) !=# s:cpath(getcwd())
|
||||||
let cwd = getcwd()
|
let cwd = getcwd()
|
||||||
execute cd s:fnameescape(tree)
|
execute cd s:fnameescape(tree)
|
||||||
@ -2382,7 +2386,7 @@ function! s:Blame(bang, line1, line2, count, mods, args) abort
|
|||||||
endif
|
endif
|
||||||
let top = line('w0') + &scrolloff
|
let top = line('w0') + &scrolloff
|
||||||
let current = line('.')
|
let current = line('.')
|
||||||
let s:temp_files[s:cpath(temp)] = { 'dir': s:repo().dir(), 'args': cmd }
|
let s:temp_files[s:cpath(temp)] = { 'dir': b:git_dir, 'args': cmd }
|
||||||
exe 'keepalt leftabove vsplit '.temp
|
exe 'keepalt leftabove vsplit '.temp
|
||||||
let b:fugitive_blamed_bufnr = bufnr
|
let b:fugitive_blamed_bufnr = bufnr
|
||||||
let b:fugitive_type = 'blame'
|
let b:fugitive_type = 'blame'
|
||||||
@ -2616,11 +2620,11 @@ function! s:Browse(bang,line1,count,...) abort
|
|||||||
let type = 'blob'
|
let type = 'blob'
|
||||||
endif
|
endif
|
||||||
let path = path[1:-1]
|
let path = path[1:-1]
|
||||||
elseif s:repo().bare()
|
elseif empty(s:Tree())
|
||||||
let path = '.git/' . full[strlen(s:repo().dir())+1:-1]
|
let path = '.git/' . full[strlen(b:git_dir)+1:-1]
|
||||||
let type = ''
|
let type = ''
|
||||||
else
|
else
|
||||||
let path = full[strlen(s:repo().tree())+1:-1]
|
let path = full[strlen(s:Tree())+1:-1]
|
||||||
if path =~# '^\.git/'
|
if path =~# '^\.git/'
|
||||||
let type = ''
|
let type = ''
|
||||||
elseif isdirectory(full)
|
elseif isdirectory(full)
|
||||||
@ -2632,8 +2636,8 @@ function! s:Browse(bang,line1,count,...) abort
|
|||||||
if type ==# 'tree' && !empty(path)
|
if type ==# 'tree' && !empty(path)
|
||||||
let path = s:sub(path, '/\=$', '/')
|
let path = s:sub(path, '/\=$', '/')
|
||||||
endif
|
endif
|
||||||
if path =~# '^\.git/.*HEAD' && filereadable(s:repo().dir(path[5:-1]))
|
if path =~# '^\.git/.*HEAD' && filereadable(b:git_dir . '/' . path[5:-1])
|
||||||
let body = readfile(s:repo().dir(path[5:-1]))[0]
|
let body = readfile(b:git_dir . '/' . path[5:-1])[0]
|
||||||
if body =~# '^\x\{40\}$'
|
if body =~# '^\x\{40\}$'
|
||||||
let commit = body
|
let commit = body
|
||||||
let type = 'commit'
|
let type = 'commit'
|
||||||
@ -2655,7 +2659,7 @@ function! s:Browse(bang,line1,count,...) abort
|
|||||||
elseif path =~# '^\.git/refs/heads/.'
|
elseif path =~# '^\.git/refs/heads/.'
|
||||||
let branch = path[16:-1]
|
let branch = path[16:-1]
|
||||||
elseif !exists('branch')
|
elseif !exists('branch')
|
||||||
let branch = s:repo().head()
|
let branch = FugitiveHead()
|
||||||
endif
|
endif
|
||||||
if !empty(branch)
|
if !empty(branch)
|
||||||
let r = fugitive#Config('branch.'.branch.'.remote')
|
let r = fugitive#Config('branch.'.branch.'.remote')
|
||||||
@ -2812,7 +2816,7 @@ function! fugitive#BufReadStatus() abort
|
|||||||
if exists('old_index')
|
if exists('old_index')
|
||||||
let $GIT_INDEX_FILE = amatch
|
let $GIT_INDEX_FILE = amatch
|
||||||
endif
|
endif
|
||||||
execute cd s:fnameescape(FugitiveTreeForGitDir(dir))
|
execute cd s:fnameescape(s:Tree(dir))
|
||||||
call s:ReplaceCmd(cmd_str)
|
call s:ReplaceCmd(cmd_str)
|
||||||
finally
|
finally
|
||||||
if exists('old_index')
|
if exists('old_index')
|
||||||
@ -2904,7 +2908,7 @@ function! fugitive#FileWriteCmd(...) abort
|
|||||||
let sha1 = readfile(tmp)[0]
|
let sha1 = readfile(tmp)[0]
|
||||||
let old_mode = matchstr(system(s:Prepare(dir, 'ls-files', '--stage', file[1:-1])), '^\d\+')
|
let old_mode = matchstr(system(s:Prepare(dir, 'ls-files', '--stage', file[1:-1])), '^\d\+')
|
||||||
if old_mode == ''
|
if old_mode == ''
|
||||||
let old_mode = executable(FugitiveTreeForGitDir(dir) . file) ? '100755' : '100644'
|
let old_mode = executable(s:Tree(dir) . file) ? '100755' : '100644'
|
||||||
endif
|
endif
|
||||||
let info = old_mode.' '.sha1.' '.commit."\t".file[1:-1]
|
let info = old_mode.' '.sha1.' '.commit."\t".file[1:-1]
|
||||||
call writefile([info],tmp)
|
call writefile([info],tmp)
|
||||||
|
@ -25,7 +25,7 @@ endfunction
|
|||||||
|
|
||||||
let s:worktree_for_dir = {}
|
let s:worktree_for_dir = {}
|
||||||
let s:dir_for_worktree = {}
|
let s:dir_for_worktree = {}
|
||||||
function! FugitiveTreeForGitDir(...) abort
|
function! FugitiveWorkTree(...) abort
|
||||||
let dir = substitute(s:shellslash(a:0 ? a:1 : get(b:, 'git_dir', '')), '/$', '', '')
|
let dir = substitute(s:shellslash(a:0 ? a:1 : get(b:, 'git_dir', '')), '/$', '', '')
|
||||||
if dir =~# '/\.git$'
|
if dir =~# '/\.git$'
|
||||||
return len(dir) ==# 5 ? '/' : dir[0:-6]
|
return len(dir) ==# 5 ? '/' : dir[0:-6]
|
||||||
@ -57,6 +57,10 @@ function! FugitiveTreeForGitDir(...) abort
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! FugitiveTreeForGitDir(path) abort
|
||||||
|
return FugitiveWorkTree(a:path)
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! FugitiveExtractGitDir(path) abort
|
function! FugitiveExtractGitDir(path) abort
|
||||||
let path = s:shellslash(a:path)
|
let path = s:shellslash(a:path)
|
||||||
if path =~# '^fugitive:'
|
if path =~# '^fugitive:'
|
||||||
@ -86,7 +90,7 @@ function! FugitiveExtractGitDir(path) abort
|
|||||||
return simplify(fnamemodify($GIT_DIR, ':p:s?[\/]$??'))
|
return simplify(fnamemodify($GIT_DIR, ':p:s?[\/]$??'))
|
||||||
endif
|
endif
|
||||||
if FugitiveIsGitDir($GIT_DIR)
|
if FugitiveIsGitDir($GIT_DIR)
|
||||||
call FugitiveTreeForGitDir(simplify(fnamemodify($GIT_DIR, ':p:s?[\/]$??')))
|
call FugitiveWorkTree(simplify(fnamemodify($GIT_DIR, ':p:s?[\/]$??')))
|
||||||
if has_key(s:dir_for_worktree, root)
|
if has_key(s:dir_for_worktree, root)
|
||||||
return s:dir_for_worktree[root]
|
return s:dir_for_worktree[root]
|
||||||
endif
|
endif
|
||||||
|
Loading…
Reference in New Issue
Block a user