Skip to content

Commit

Permalink
Use fugitive#Execute with --literal-pathspecs
Browse files Browse the repository at this point in the history
  • Loading branch information
mvanderkamp committed Oct 18, 2021
1 parent 7b0825d commit 13f3b39
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions autoload/fugitive.vim
Original file line number Diff line number Diff line change
Expand Up @@ -2049,15 +2049,17 @@ function! s:PathInfo(url) abort
let [_, ftime] = s:TreeInfo(dir, commit)
let entry = [ftime, '040000', 'tree', '', -1]
elseif commit =~# '^:\=[0-3]$'
let [lines, exec_error] = s:LinesError([dir, 'ls-files', '--stage', '--', path])
if exec_error || empty(lines)
let result = fugitive#Execute(['--literal-pathspecs', 'ls-files', '--stage', '--', path])
let line = result.stdout[0]
if result.exit_status || empty(line)
return [-1, '000000', '', '', -1]
endif
let newftime = getftime(fugitive#Find('.git/index', dir))
if len(lines) > 1
if !empty(get(result.stdout, 1, ''))
" Multiple files reported for one path, assume path is a directory
let entry = [newftime, '040000', 'tree', '', -1]
else
let [info, filename] = split(lines[0], "\t")
let [info, filename] = split(line, "\t")
let [mode, sha, stage] = split(info, '\s\+')
let entry = [newftime, mode, 'blob', sha, -2]
endif
Expand Down

0 comments on commit 13f3b39

Please sign in to comment.