From 85639a20fb87c3884d890b6db82ae0f60b1b16b6 Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Wed, 14 Mar 2012 20:16:49 -0400 Subject: [PATCH] Support bare repositories that don't end in .git Closes #117 and supports #139. --- plugin/fugitive.vim | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim index f65bcdb..69e4b03 100644 --- a/plugin/fugitive.vim +++ b/plugin/fugitive.vim @@ -107,6 +107,11 @@ let s:abstract_prototype = {} " }}}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 let path = s:shellslash(a:path) if path =~? '^fugitive://.*//' @@ -115,10 +120,10 @@ function! s:extract_git_dir(path) abort let fn = fnamemodify(path,':s?[\/]$??') let ofn = "" let nfn = fn - while fn !=# ofn && fn !=# '/' - if filereadable(fn . '/.git/HEAD') + while fn !=# ofn + if s:is_git_dir(s:sub(fn,'[\/]$','') . '/.git') 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$','') endif let ofn = fn