Skip to content

Commit

Permalink
Only query requested path in stage objects
Browse files Browse the repository at this point in the history
  • Loading branch information
mvanderkamp committed Oct 19, 2021
1 parent 4d29c1d commit c9c40c1
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions autoload/fugitive.vim
Original file line number Diff line number Diff line change
Expand Up @@ -2075,8 +2075,31 @@ function! s:PathInfo(url) abort
return [-1, '000000', '', '', -1]
endif
let path = substitute(file[1:-1], '/*$', '', '')
let [tree, ftime] = s:TreeInfo(dir, commit)
let entry = empty(path) ? [ftime, '040000', 'tree', '', -1] : get(tree, path, [])

if empty(path)
let [_, ftime] = s:TreeInfo(dir, commit)
let entry = [ftime, '040000', 'tree', '', -1]
elseif commit =~# '^:\=[0-3]$'
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))
let indexes = {}
let [info, filename] = split(line, "\t")
let [mode, sha, stage] = split(info, '\s\+')
let indexes[filename] = [newftime, mode, 'blob', sha, -2]
while filename =~# '/'
let filename = substitute(filename, '/[^/]*$', '', '')
let indexes[filename] = [newftime, '040000', 'tree', '', 0]
endwhile
let entry = get(indexes, path, [])
else
let [tree, ftime] = s:TreeInfo(dir, commit)
let entry = get(tree, path, [])
endif

if empty(entry) || file =~# '/$' && entry[2] !=# 'tree'
return [-1, '000000', '', '', -1]
else
Expand Down

0 comments on commit c9c40c1

Please sign in to comment.