mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-13 05:43:52 -05:00
Support bare repositories that don't end in .git
Closes #117 and supports #139.
This commit is contained in:
@@ -107,6 +107,11 @@ let s:abstract_prototype = {}
|
|||||||
" }}}1
|
" }}}1
|
||||||
" Initialization {{{1
|
" Initialization {{{1
|
||||||
|
|
||||||
|
function! s:is_git_dir(path) abort
|
||||||
|
let path = a:path . '/'
|
||||||
|
return isdirectory(path.'objects') && isdirectory(path.'refs') && filereadable(path.'HEAD') && filereadable(path.'config')
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! s:extract_git_dir(path) abort
|
function! s:extract_git_dir(path) abort
|
||||||
let path = s:shellslash(a:path)
|
let path = s:shellslash(a:path)
|
||||||
if path =~? '^fugitive://.*//'
|
if path =~? '^fugitive://.*//'
|
||||||
@@ -115,10 +120,10 @@ function! s:extract_git_dir(path) abort
|
|||||||
let fn = fnamemodify(path,':s?[\/]$??')
|
let fn = fnamemodify(path,':s?[\/]$??')
|
||||||
let ofn = ""
|
let ofn = ""
|
||||||
let nfn = fn
|
let nfn = fn
|
||||||
while fn !=# ofn && fn !=# '/'
|
while fn !=# ofn
|
||||||
if filereadable(fn . '/.git/HEAD')
|
if s:is_git_dir(s:sub(fn,'[\/]$','') . '/.git')
|
||||||
return s:sub(simplify(fnamemodify(fn . '/.git',':p')),'\W$','')
|
return s:sub(simplify(fnamemodify(fn . '/.git',':p')),'\W$','')
|
||||||
elseif fn =~ '\.git$' && filereadable(fn . '/HEAD')
|
elseif s:is_git_dir(fn)
|
||||||
return s:sub(simplify(fnamemodify(fn,':p')),'\W$','')
|
return s:sub(simplify(fnamemodify(fn,':p')),'\W$','')
|
||||||
endif
|
endif
|
||||||
let ofn = fn
|
let ofn = fn
|
||||||
|
|||||||
Reference in New Issue
Block a user