Skip to content

Commit 7b0825d

Browse files
committed
Distinguish between tree and blob paths
The assumption here is that if `git ls-files <file>` returns more than one line for a given `<file>` that this means the file is a tree, but if it only returns one line then the file is a blob.
1 parent b691cfe commit 7b0825d

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

autoload/fugitive.vim

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2054,9 +2054,13 @@ function! s:PathInfo(url) abort
20542054
return [-1, '000000', '', '', -1]
20552055
endif
20562056
let newftime = getftime(fugitive#Find('.git/index', dir))
2057-
let [info, filename] = split(lines[0], "\t")
2058-
let [mode, sha, stage] = split(info, '\s\+')
2059-
let entry = [newftime, mode, 'blob', sha, -2]
2057+
if len(lines) > 1
2058+
let entry = [newftime, '040000', 'tree', '', -1]
2059+
else
2060+
let [info, filename] = split(lines[0], "\t")
2061+
let [mode, sha, stage] = split(info, '\s\+')
2062+
let entry = [newftime, mode, 'blob', sha, -2]
2063+
endif
20602064
else
20612065
let [tree, ftime] = s:TreeInfo(dir, commit)
20622066
let entry = get(tree, path, [])

0 commit comments

Comments
 (0)