Skip to content

Commit 13f3b39

Browse files
committed
Use fugitive#Execute with --literal-pathspecs
1 parent 7b0825d commit 13f3b39

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

autoload/fugitive.vim

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2049,15 +2049,17 @@ function! s:PathInfo(url) abort
20492049
let [_, ftime] = s:TreeInfo(dir, commit)
20502050
let entry = [ftime, '040000', 'tree', '', -1]
20512051
elseif commit =~# '^:\=[0-3]$'
2052-
let [lines, exec_error] = s:LinesError([dir, 'ls-files', '--stage', '--', path])
2053-
if exec_error || empty(lines)
2052+
let result = fugitive#Execute(['--literal-pathspecs', 'ls-files', '--stage', '--', path])
2053+
let line = result.stdout[0]
2054+
if result.exit_status || empty(line)
20542055
return [-1, '000000', '', '', -1]
20552056
endif
20562057
let newftime = getftime(fugitive#Find('.git/index', dir))
2057-
if len(lines) > 1
2058+
if !empty(get(result.stdout, 1, ''))
2059+
" Multiple files reported for one path, assume path is a directory
20582060
let entry = [newftime, '040000', 'tree', '', -1]
20592061
else
2060-
let [info, filename] = split(lines[0], "\t")
2062+
let [info, filename] = split(line, "\t")
20612063
let [mode, sha, stage] = split(info, '\s\+')
20622064
let entry = [newftime, mode, 'blob', sha, -2]
20632065
endif

0 commit comments

Comments
 (0)