Shallow clone by default (#122 #217)

This commit is contained in:
Junegunn Choi
2015-04-25 13:14:27 +09:00
parent 42300e0c4d
commit c632c1fd6a
3 changed files with 18 additions and 8 deletions

View File

@@ -763,6 +763,9 @@ function! s:update_impl(pull, force, args) abort
call append(0, ['', ''])
normal! 2G
let s:clone_opt = get(g:, 'plug_shallow', 1) ?
\ '--depth 1' . (s:git_version_requirement(1, 7, 10) ? ' --no-single-branch' : '') : ''
" Python version requirement (>= 2.7)
if s:py2 && !s:ruby && !s:nvim && s:update.threads > 1
redir => pyv
@@ -979,7 +982,8 @@ while 1 " Without TCO, Vim stack is bound to explode
endif
else
call s:spawn(name,
\ printf('git clone %s --recursive %s -b %s %s 2>&1',
\ printf('git clone %s %s --recursive %s -b %s %s 2>&1',
\ s:clone_opt,
\ prog,
\ s:shellesc(spec.uri),
\ checkout,
@@ -1016,6 +1020,7 @@ import vim
G_PULL = vim.eval('s:update.pull') == '1'
G_RETRIES = int(vim.eval('get(g:, "plug_retries", 2)')) + 1
G_TIMEOUT = int(vim.eval('get(g:, "plug_timeout", 60)'))
G_CLONE_OPT = vim.eval('s:clone_opt')
G_PROGRESS = vim.eval('s:progress_opt(1)')
G_LOG_PROB = 1.0 / int(vim.eval('s:update.threads'))
G_STOP = thr.Event()
@@ -1237,8 +1242,8 @@ class Plugin(object):
self.write(Action.INSTALL, self.name, ['Installing ...'])
callback = functools.partial(self.buf.write, Action.INSTALL, self.name)
cmd = 'git clone {0} --recursive {1} -b {2} {3} 2>&1'.format(
G_PROGRESS, self.args['uri'], self.checkout, esc(target))
cmd = 'git clone {0} {1} --recursive {2} -b {3} {4} 2>&1'.format(
G_CLONE_OPT, G_PROGRESS, self.args['uri'], self.checkout, esc(target))
com = Command(cmd, None, G_TIMEOUT, G_RETRIES, callback, clean(target))
result = com.attempt_cmd()
self.write(Action.DONE, self.name, result[-1:])
@@ -1533,6 +1538,7 @@ function! s:update_ruby()
end
} if VIM::evaluate('s:mac_gui') == 1
clone_opt = VIM::evaluate('s:clone_opt')
progress = VIM::evaluate('s:progress_opt(1)')
nthr.times do
mtx.synchronize do
@@ -1570,7 +1576,7 @@ function! s:update_ruby()
else
d = esc dir.sub(%r{[\\/]+$}, '')
log.call name, 'Installing ...', :install
bt.call "git clone #{progress} --recursive #{uri} -b #{checkout} #{d} 2>&1", name, :install, proc {
bt.call "git clone #{clone_opt} #{progress} --recursive #{uri} -b #{checkout} #{d} 2>&1", name, :install, proc {
FileUtils.rm_rf dir
}
end