Skip to content

Commit c2e6f9f

Browse files
author
Stephan Dilly
committed
filetree paniced on non utf8 files/paths
1 parent f1d2c7a commit c2e6f9f

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616
- openssl vendoring broken on macos ([#772](https://github.com/extrawurst/gitui/issues/772))
1717
- amend and other commands not shown in help ([#778](https://github.com/extrawurst/gitui/issues/778))
1818
- focus locked on commit msg details in narrow term sizes ([#780](https://github.com/extrawurst/gitui/issues/780))
19+
- non-utf8 file/path names broke filetree ([#802](https://github.com/extrawurst/gitui/issues/802))
1920

2021
## [0.16.1] - 2021-06-06
2122

asyncgit/src/sync/tree.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::{utils::bytes2string, CommitId};
1+
use super::CommitId;
22
use crate::{
33
error::{Error, Result},
44
sync::utils::repo,
@@ -101,7 +101,8 @@ fn tree_recurse(
101101
out.reserve(tree.len());
102102

103103
for e in tree {
104-
let path = path.join(bytes2string(e.name_bytes())?);
104+
let p = String::from_utf8_lossy(e.name_bytes());
105+
let path = path.join(p.to_string());
105106
match e.kind() {
106107
Some(git2::ObjectType::Blob) => {
107108
let id = e.id();

filetreelist/src/filetree.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,10 @@ impl FileTree {
5555

5656
///
5757
pub fn collapse_but_root(&mut self) {
58-
self.items.collapse(0, true);
59-
self.items.expand(0, false);
58+
if !self.is_empty() {
59+
self.items.collapse(0, true);
60+
self.items.expand(0, false);
61+
}
6062
}
6163

6264
/// iterates visible elements starting from `start_index_visual`

0 commit comments

Comments
 (0)