Skip to content

Commit b6050d6

Browse files
authored
Allow cloning into an empty directory (#782)
Close #766 We can rely on git to check if the destination directory is empty.
1 parent 7f8fdd0 commit b6050d6

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

plug.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1331,7 +1331,7 @@ while 1 " Without TCO, Vim stack is bound to explode
13311331

13321332
let name = keys(s:update.todo)[0]
13331333
let spec = remove(s:update.todo, name)
1334-
let new = !isdirectory(spec.dir)
1334+
let new = empty(globpath(spec.dir, '.git', 1))
13351335

13361336
call s:log(new ? '+' : '*', name, pull ? 'Updating ...' : 'Installing ...')
13371337
redraw

test/workflow.vader

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1511,7 +1511,7 @@ Execute (Commit hash support):
15111511
Log getline(1, '$')
15121512
AssertEqual 'x goyo.vim:', getline(5)
15131513
AssertEqual ' fatal: invalid reference: ffffffff', getline(6)
1514-
AssertEqual 0, stridx(getline(7), '- vim-emoji: HEAD is now at 9db7fcf...')
1514+
AssertEqual 0, stridx(getline(7), '- vim-emoji: HEAD is now at 9db7fcf')
15151515

15161516
let hash = system(printf('cd %s && git rev-parse HEAD', g:plugs['vim-emoji'].dir))[:-2]
15171517
AssertEqual '9db7fcfee0d90dafdbcb7a32090c0a9085eb054a', hash
@@ -1638,3 +1638,15 @@ Execute (#532 - Reuse plug window):
16381638
AssertEqual 2, winnr(), 'Current window is #2 after PlugStatus (but is '.winnr().')'
16391639
AssertEqual 2, winnr('$'), 'Three windows after PlugStatus (but got '.winnr('$').')'
16401640
q
1641+
1642+
Execute (#766 - Allow cloning into an empty directory):
1643+
let d = '/tmp/vim-plug-test/goyo-already'
1644+
call system('rm -rf ' . d)
1645+
call mkdir(d)
1646+
call plug#begin()
1647+
Plug 'junegunn/goyo.vim', { 'dir': d }
1648+
call plug#end()
1649+
PlugInstall
1650+
AssertExpect! '[=]', 1
1651+
q
1652+
unlet d

0 commit comments

Comments
 (0)