mirror of
https://github.com/junegunn/vim-plug.git
synced 2024-12-19 10:35:38 -07:00
Append -- to git checkout commands
Checking out a branch or tag may not succeed if there is a path entry with the same name. This commit appends -- to git checkout commands to clarify that we're not referring to a file or a directory. Close #602
This commit is contained in:
parent
e3252aae2c
commit
769192d3d0
8
plug.vim
8
plug.vim
@ -868,7 +868,7 @@ function! s:checkout(spec)
|
|||||||
let output = s:system('git rev-parse HEAD', a:spec.dir)
|
let output = s:system('git rev-parse HEAD', a:spec.dir)
|
||||||
if !v:shell_error && !s:hash_match(sha, s:lines(output)[0])
|
if !v:shell_error && !s:hash_match(sha, s:lines(output)[0])
|
||||||
let output = s:system(
|
let output = s:system(
|
||||||
\ 'git fetch --depth 999999 && git checkout '.s:esc(sha), a:spec.dir)
|
\ 'git fetch --depth 999999 && git checkout '.s:esc(sha).' --', a:spec.dir)
|
||||||
endif
|
endif
|
||||||
return output
|
return output
|
||||||
endfunction
|
endfunction
|
||||||
@ -1067,11 +1067,11 @@ function! s:update_finish()
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
call s:log4(name, 'Checking out '.tag)
|
call s:log4(name, 'Checking out '.tag)
|
||||||
let out = s:system('git checkout -q '.s:esc(tag).' 2>&1', spec.dir)
|
let out = s:system('git checkout -q '.s:esc(tag).' -- 2>&1', spec.dir)
|
||||||
else
|
else
|
||||||
let branch = s:esc(get(spec, 'branch', 'master'))
|
let branch = s:esc(get(spec, 'branch', 'master'))
|
||||||
call s:log4(name, 'Merging origin/'.branch)
|
call s:log4(name, 'Merging origin/'.branch)
|
||||||
let out = s:system('git checkout -q '.branch.' 2>&1'
|
let out = s:system('git checkout -q '.branch.' -- 2>&1'
|
||||||
\. (has_key(s:update.new, name) ? '' : ('&& git merge --ff-only origin/'.branch.' 2>&1')), spec.dir)
|
\. (has_key(s:update.new, name) ? '' : ('&& git merge --ff-only origin/'.branch.' 2>&1')), spec.dir)
|
||||||
endif
|
endif
|
||||||
if !v:shell_error && filereadable(spec.dir.'/.gitmodules') &&
|
if !v:shell_error && filereadable(spec.dir.'/.gitmodules') &&
|
||||||
@ -2390,7 +2390,7 @@ function! s:revert()
|
|||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call s:system('git reset --hard HEAD@{1} && git checkout '.s:esc(g:plugs[name].branch), g:plugs[name].dir)
|
call s:system('git reset --hard HEAD@{1} && git checkout '.s:esc(g:plugs[name].branch).' --', g:plugs[name].dir)
|
||||||
setlocal modifiable
|
setlocal modifiable
|
||||||
normal! "_dap
|
normal! "_dap
|
||||||
setlocal nomodifiable
|
setlocal nomodifiable
|
||||||
|
@ -341,3 +341,16 @@ Execute (#593 Add plugin to &rtp before running post-update hook with : prefix):
|
|||||||
call plug#end()
|
call plug#end()
|
||||||
PlugInstall!
|
PlugInstall!
|
||||||
AssertEqual ['a', 'b'], g:bar
|
AssertEqual ['a', 'b'], g:bar
|
||||||
|
|
||||||
|
**********************************************************************
|
||||||
|
Execute (#602 Confusion with branch name and path name):
|
||||||
|
call plug#begin()
|
||||||
|
Plug expand('file:////tmp/vim-plug-test/new-branch'), { 'branch': 'plugin' }
|
||||||
|
call plug#end()
|
||||||
|
PlugUpdate
|
||||||
|
call PlugStatusSorted()
|
||||||
|
|
||||||
|
Expect:
|
||||||
|
- new-branch: OK
|
||||||
|
Finished. 0 error(s).
|
||||||
|
[=]
|
||||||
|
2
test/run
2
test/run
@ -95,6 +95,8 @@ DOC
|
|||||||
echo 'let g:foo = 1' > plugin/foo.vim
|
echo 'let g:foo = 1' > plugin/foo.vim
|
||||||
git add plugin/foo.vim
|
git add plugin/foo.vim
|
||||||
git commit -m initial
|
git commit -m initial
|
||||||
|
git checkout -b plugin
|
||||||
|
git checkout master
|
||||||
|
|
||||||
cd "$BASE"
|
cd "$BASE"
|
||||||
}
|
}
|
||||||
|
@ -1473,7 +1473,7 @@ Execute (Commit hash support):
|
|||||||
PlugUpdate
|
PlugUpdate
|
||||||
Log getline(1, '$')
|
Log getline(1, '$')
|
||||||
AssertEqual 'x goyo.vim:', getline(5)
|
AssertEqual 'x goyo.vim:', getline(5)
|
||||||
AssertEqual ' error: pathspec ''ffffffff'' did not match any file(s) known to git.', getline(6)
|
AssertEqual ' fatal: invalid reference: ffffffff', getline(6)
|
||||||
AssertEqual 0, stridx(getline(7), '- vim-emoji: HEAD is now at 9db7fcf...')
|
AssertEqual 0, stridx(getline(7), '- vim-emoji: HEAD is now at 9db7fcf...')
|
||||||
|
|
||||||
let hash = system(printf('cd %s && git rev-parse HEAD', g:plugs['vim-emoji'].dir))[:-2]
|
let hash = system(printf('cd %s && git rev-parse HEAD', g:plugs['vim-emoji'].dir))[:-2]
|
||||||
|
Loading…
Reference in New Issue
Block a user