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 <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
This commit is contained in:
Fintan Halpenny
2022-12-16 11:37:58 +00:00
parent d957f0b1c2
commit 95c31f2a8e
+3 -2
View File
@@ -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);