From 0abfd7f70494bb67ec06df34bc54d9d3660b821e Mon Sep 17 00:00:00 2001 From: Marwan Al Jubeh Date: Thu, 24 Nov 2011 17:43:24 +0200 Subject: [PATCH] If the user's .vim directory is under source control (git), add bundles as proper submodules (using relative paths) --- autoload/vundle/installer.vim | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/autoload/vundle/installer.vim b/autoload/vundle/installer.vim index a086e32..d61a5eb 100644 --- a/autoload/vundle/installer.vim +++ b/autoload/vundle/installer.vim @@ -202,7 +202,15 @@ func! s:sync(bang, bundle) abort let cmd = '"'.cmd.'"' " enclose in quotes endif else - let cmd = 'git clone '.a:bundle.uri.' '.shellescape(a:bundle.path()) + call s:system('cd '.shellescape(g:bundle_dir).'; git status') + if v:shell_error + let cmd = 'git clone '.a:bundle.uri.' '.shellescape(a:bundle.path()) + else + let top_level = substitute(s:system('cd '.shellescape(g:bundle_dir).'; git rev-parse --show-toplevel'), '\n', '', 'g') + let prefix = substitute(s:system('cd '.shellescape(g:bundle_dir).'; git rev-parse --show-prefix'), '\n', '', 'g') + let relative_path = prefix.substitute(a:bundle.path(), g:bundle_dir.'/', '', '') + let cmd = 'cd '.shellescape(top_level).'; git submodule add '.a:bundle.uri.' '.shellescape(relative_path) + endif endif let out = s:system(cmd)