mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-15 06:43:51 -05:00
Support .git-file repositories
This supports the new submodule structure and closes #139.
This commit is contained in:
@@ -121,8 +121,14 @@ function! s:extract_git_dir(path) abort
|
|||||||
let ofn = ""
|
let ofn = ""
|
||||||
let nfn = fn
|
let nfn = fn
|
||||||
while fn !=# ofn
|
while fn !=# ofn
|
||||||
if s:is_git_dir(s:sub(fn,'[\/]$','') . '/.git')
|
let embedded = s:sub(fn, '[\/]$', '') . '/.git'
|
||||||
|
if s:is_git_dir(embedded)
|
||||||
return s:sub(simplify(fnamemodify(fn . '/.git',':p')),'\W$','')
|
return s:sub(simplify(fnamemodify(fn . '/.git',':p')),'\W$','')
|
||||||
|
elseif filereadable(embedded)
|
||||||
|
let line = readfile(embedded,1)[0]
|
||||||
|
if line =~# '^gitdir: '
|
||||||
|
return line[8:-1]
|
||||||
|
endif
|
||||||
elseif s:is_git_dir(fn)
|
elseif s:is_git_dir(fn)
|
||||||
return s:sub(simplify(fnamemodify(fn,':p')),'\W$','')
|
return s:sub(simplify(fnamemodify(fn,':p')),'\W$','')
|
||||||
endif
|
endif
|
||||||
@@ -196,15 +202,28 @@ function! s:repo_dir(...) dict abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:repo_tree(...) dict abort
|
function! s:repo_tree(...) dict abort
|
||||||
if !self.bare()
|
if self.dir() =~# '/\.git$'
|
||||||
let dir = fnamemodify(self.git_dir,':h')
|
let dir = self.dir()[0:-6]
|
||||||
return join([dir]+a:000,'/')
|
else
|
||||||
|
let config = readfile(self.dir('config'),10)
|
||||||
|
call filter(config,'v:val =~# "^\\s*worktree *="')
|
||||||
|
if len(config) == 1
|
||||||
|
let dir = matchstr(config[0], '= *\zs.*')
|
||||||
|
else
|
||||||
|
call s:throw('no work tree')
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
call s:throw('no work tree')
|
return join([dir]+a:000,'/')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:repo_bare() dict abort
|
function! s:repo_bare() dict abort
|
||||||
return self.dir() !~# '/\.git$'
|
if self.dir() =~# '/\.git$'
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
let config = readfile(self.dir('config'),10)
|
||||||
|
call filter(config,'v:val =~# "^\\s*worktree *="')
|
||||||
|
return (len(config) != 1)
|
||||||
|
endtry
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:repo_translate(spec) dict abort
|
function! s:repo_translate(spec) dict abort
|
||||||
|
|||||||
Reference in New Issue
Block a user