Skip to content

Commit d708f0b

Browse files
committed
Only query requested path in stage objects
1 parent 4d29c1d commit d708f0b

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

autoload/fugitive.vim

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2075,8 +2075,29 @@ function! s:PathInfo(url) abort
20752075
return [-1, '000000', '', '', -1]
20762076
endif
20772077
let path = substitute(file[1:-1], '/*$', '', '')
2078-
let [tree, ftime] = s:TreeInfo(dir, commit)
2079-
let entry = empty(path) ? [ftime, '040000', 'tree', '', -1] : get(tree, path, [])
2078+
2079+
if empty(path)
2080+
let [_, ftime] = s:TreeInfo(dir, commit)
2081+
let entry = [ftime, '040000', 'tree', '', -1]
2082+
elseif commit =~# '^:\=[0-3]$'
2083+
let result = fugitive#Execute(['--literal-pathspecs', 'ls-files', '--stage', '--', path])
2084+
let line = result.stdout[0]
2085+
if result.exit_status || empty(line)
2086+
return [-1, '000000', '', '', -1]
2087+
endif
2088+
let newftime = getftime(fugitive#Find('.git/index', dir))
2089+
let [info, filename] = split(line, "\t")
2090+
if filename ==# path
2091+
let [mode, sha, stage] = split(info, '\s\+')
2092+
let entry = [newftime, mode, 'blob', sha, -2]
2093+
else
2094+
let entry = [newftime, '040000', 'tree', '', 0]
2095+
endif
2096+
else
2097+
let [tree, ftime] = s:TreeInfo(dir, commit)
2098+
let entry = get(tree, path, [])
2099+
endif
2100+
20802101
if empty(entry) || file =~# '/$' && entry[2] !=# 'tree'
20812102
return [-1, '000000', '', '', -1]
20822103
else

0 commit comments

Comments
 (0)