From 95c31f2a8e9ec0eeb2b2ef8dac6d0dd8d216d571 Mon Sep 17 00:00:00 2001 From: Fintan Halpenny Date: Wed, 14 Dec 2022 13:37:34 +0000 Subject: [PATCH] surf: fix directory construction If a git Tree is a subtree then it no longer contains the path information while traversing it. The traversal will only carry the path with it if it does not skip directories, which in the case of `entries`, it does. To remedy this, the `path` method is used to pass the information to `from_entry` instead. Signed-off-by: Fintan Halpenny X-Clacks-Overhead: GNU Terry Pratchett --- radicle-surf/src/file_system/directory.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/radicle-surf/src/file_system/directory.rs b/radicle-surf/src/file_system/directory.rs index 41eea0b..2fb8278 100644 --- a/radicle-surf/src/file_system/directory.rs +++ b/radicle-surf/src/file_system/directory.rs @@ -352,10 +352,11 @@ impl Directory { let mut entries = BTreeMap::new(); let mut error = None; + let path = self.path(); // Walks only the first level of entries. - tree.walk(git2::TreeWalkMode::PreOrder, |path, entry| { - match Entry::from_entry(entry, Path::new(path).to_path_buf()) { + tree.walk(git2::TreeWalkMode::PreOrder, |_, entry| { + match Entry::from_entry(entry, path.clone()) { Ok(Some(entry)) => match entry { Entry::File(_) => { entries.insert(entry.name().clone(), entry);