filetree paniced on non utf8 files/paths

This commit is contained in:
Stephan Dilly 2021-07-05 00:18:45 +02:00
parent f1d2c7a26c
commit c2e6f9ff7e
3 changed files with 8 additions and 4 deletions

View file

@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- openssl vendoring broken on macos ([#772](https://github.com/extrawurst/gitui/issues/772))
- amend and other commands not shown in help ([#778](https://github.com/extrawurst/gitui/issues/778))
- focus locked on commit msg details in narrow term sizes ([#780](https://github.com/extrawurst/gitui/issues/780))
- non-utf8 file/path names broke filetree ([#802](https://github.com/extrawurst/gitui/issues/802))
## [0.16.1] - 2021-06-06

View file

@ -1,4 +1,4 @@
use super::{utils::bytes2string, CommitId};
use super::CommitId;
use crate::{
error::{Error, Result},
sync::utils::repo,
@ -101,7 +101,8 @@ fn tree_recurse(
out.reserve(tree.len());
for e in tree {
let path = path.join(bytes2string(e.name_bytes())?);
let p = String::from_utf8_lossy(e.name_bytes());
let path = path.join(p.to_string());
match e.kind() {
Some(git2::ObjectType::Blob) => {
let id = e.id();

View file

@ -55,8 +55,10 @@ impl FileTree {
///
pub fn collapse_but_root(&mut self) {
self.items.collapse(0, true);
self.items.expand(0, false);
if !self.is_empty() {
self.items.collapse(0, true);
self.items.expand(0, false);
}
}
/// iterates visible elements starting from `start_index_visual`