···2525 if let Some(subtree) = &arguments.subtree {
2626 let entry = current_tree
2727 .lookup_entry_by_path(subtree)?
2828- .expect("sub-tree not found");
2929- if entry.mode().is_tree() {
3030- current_tree = repository.find_tree(entry.id())?;
2828+ .ok_or_else(|| anyhow::anyhow!("Failed to find subtree: {subtree:?}"))?;
2929+3030+ if !entry.mode().is_tree() {
3131+ Err(anyhow::anyhow!("{subtree:?} is not a subtree"))?;
3132 }
3333+3434+ current_tree = repository
3535+ .find_tree(entry.id())
3636+ .context("Searching for subtree entry's tree")?;
3237 }
33383439 // Build a set of the entry file names we are interested in.
···3742 interested.insert(entry?.filename().to_owned());
3843 }
39444040- let name_pad = interested
4545+ let name_pad = 2 + interested
4146 .iter()
4247 .fold(0, |len, filename| std::cmp::max(len, filename.len()));
4348···9297 }
9398 break;
9499 };
9595- if entry.mode().is_tree() {
9696- parent_tree = repository.find_tree(entry.id())?;
100100+ if !entry.mode().is_tree() {
101101+ // The subtree is no longer a subtree in this revision. Assume any
102102+ // remaining entries of interest belong to this commit.
103103+ for entry in interested.drain() {
104104+ output(entry.as_bstr(), ¤t_commit)?;
105105+ }
106106+ break;
97107 }
108108+ parent_tree = repository.find_tree(entry.id())?;
98109 }
99110100111 let mut scanner = EntryScanner::new(current_tree.iter(), parent_tree.iter())?;
···257268 Err(_) => {
258269 let id = self
259270 .find_reference(spec)
260260- .context("Failed to resolve reference in repository {}")?
271271+ .context("Failed to resolve reference in repository")?
261272 .into_fully_peeled_id()?;
262273263274 self.find_commit(id)