+18
-7
src/main.rs
+18
-7
src/main.rs
···
25
25
if let Some(subtree) = &arguments.subtree {
26
26
let entry = current_tree
27
27
.lookup_entry_by_path(subtree)?
28
-
.expect("sub-tree not found");
29
-
if entry.mode().is_tree() {
30
-
current_tree = repository.find_tree(entry.id())?;
28
+
.ok_or_else(|| anyhow::anyhow!("Failed to find subtree: {subtree:?}"))?;
29
+
30
+
if !entry.mode().is_tree() {
31
+
Err(anyhow::anyhow!("{subtree:?} is not a subtree"))?;
31
32
}
33
+
34
+
current_tree = repository
35
+
.find_tree(entry.id())
36
+
.context("Searching for subtree entry's tree")?;
32
37
}
33
38
34
39
// Build a set of the entry file names we are interested in.
···
37
42
interested.insert(entry?.filename().to_owned());
38
43
}
39
44
40
-
let name_pad = interested
45
+
let name_pad = 2 + interested
41
46
.iter()
42
47
.fold(0, |len, filename| std::cmp::max(len, filename.len()));
43
48
···
92
97
}
93
98
break;
94
99
};
95
-
if entry.mode().is_tree() {
96
-
parent_tree = repository.find_tree(entry.id())?;
100
+
if !entry.mode().is_tree() {
101
+
// The subtree is no longer a subtree in this revision. Assume any
102
+
// remaining entries of interest belong to this commit.
103
+
for entry in interested.drain() {
104
+
output(entry.as_bstr(), ¤t_commit)?;
105
+
}
106
+
break;
97
107
}
108
+
parent_tree = repository.find_tree(entry.id())?;
98
109
}
99
110
100
111
let mut scanner = EntryScanner::new(current_tree.iter(), parent_tree.iter())?;
···
257
268
Err(_) => {
258
269
let id = self
259
270
.find_reference(spec)
260
-
.context("Failed to resolve reference in repository {}")?
271
+
.context("Failed to resolve reference in repository")?
261
272
.into_fully_peeled_id()?;
262
273
263
274
self.find_commit(id)