sorted() always produces a list, so the content we pass to __get_file_in_tree here is a list. But if the file we're trying
to get is a symlink, we wind up in this section of __get_file_in_tree which implicitly assumes tree (the second
arg) must be a pygit2 Tree, because it tries to index it using
a bytestring.
If tree is actually a list, trying to index it with a bytestring
produces a TypeError not a KeyError, so the simplest fix is
to just catch that exception too.
There's a codepath in
ui.repo.view_filewhere we call__get_file_in_tree()and pass it a second argument that is nota pygit2
Tree, it's just a list:sorted()always produces a list, so thecontentwe pass to__get_file_in_treehere is a list. But if the file we're tryingto get is a symlink, we wind up in this section of
__get_file_in_treewhich implicitly assumestree(the secondarg) must be a pygit2
Tree, because it tries to index it usinga bytestring.
If
treeis actually a list, trying to index it with a bytestringproduces a
TypeErrornot aKeyError, so the simplest fix isto just catch that exception too.
Signed-off-by: Adam Williamson awilliam@redhat.com