mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-14 22:33: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 nfn = fn
|
||||
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$','')
|
||||
elseif filereadable(embedded)
|
||||
let line = readfile(embedded,1)[0]
|
||||
if line =~# '^gitdir: '
|
||||
return line[8:-1]
|
||||
endif
|
||||
elseif s:is_git_dir(fn)
|
||||
return s:sub(simplify(fnamemodify(fn,':p')),'\W$','')
|
||||
endif
|
||||
@@ -196,15 +202,28 @@ function! s:repo_dir(...) dict abort
|
||||
endfunction
|
||||
|
||||
function! s:repo_tree(...) dict abort
|
||||
if !self.bare()
|
||||
let dir = fnamemodify(self.git_dir,':h')
|
||||
return join([dir]+a:000,'/')
|
||||
endif
|
||||
if self.dir() =~# '/\.git$'
|
||||
let dir = self.dir()[0:-6]
|
||||
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
|
||||
return join([dir]+a:000,'/')
|
||||
endfunction
|
||||
|
||||
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
|
||||
|
||||
function! s:repo_translate(spec) dict abort
|
||||
|
||||
Reference in New Issue
Block a user