Skip to content

Commit d5edbd7

Browse files
committed
Report info for the correct stage
1 parent 0101f49 commit d5edbd7

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

autoload/fugitive.vim

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2071,18 +2071,29 @@ endfunction
20712071

20722072
function! s:IndexInfo(dir, commit_stage, path) abort
20732073
let result = fugitive#Execute(['--literal-pathspecs', 'ls-files', '--stage', '--', a:path])
2074-
let line = result.stdout[0]
2075-
if result.exit_status || empty(line)
2074+
if result.exit_status
20762075
return []
20772076
endif
20782077
let newftime = getftime(fugitive#Find('.git/index', a:dir))
2079-
let [info, filename] = split(line, "\t")
2080-
if filename ==# a:path
2078+
for line in result.stdout[:2]
2079+
" Inspect up to the first three lines to find the correct stage
2080+
if empty(line)
2081+
break
2082+
endif
2083+
let [info, filename] = split(line, "\t")
20812084
let [mode, sha, stage] = split(info, '\s\+')
2082-
return [newftime, mode, 'blob', sha, -2]
2083-
else
2084-
return [newftime, '040000', 'tree', '', 0]
2085-
endif
2085+
if filename ==# a:path
2086+
if stage != a:commit_stage
2087+
continue
2088+
endif
2089+
return [newftime, mode, 'blob', sha, -2]
2090+
else
2091+
" Not concerned about the stage of tree objects- a tree can contain
2092+
" blobs from many different stages simultaneously
2093+
return [newftime, '040000', 'tree', '', 0]
2094+
endif
2095+
endfor
2096+
return []
20862097
endfunction
20872098

20882099
function! s:PathInfo(url) abort

0 commit comments

Comments
 (0)