Skip to content

Commit f049b00

Browse files
committed
Don't ignore gix_diff::tree errors
1 parent 74565bc commit f049b00

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

gix-blame/src/file/function.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -328,14 +328,16 @@ fn tree_diff_at_file_path(
328328
stats.trees_decoded += 1;
329329

330330
let mut recorder = Recorder::new(file_path.into());
331-
// TODO
332-
// `recorder` cancels the traversal by returning `Cancel` when a change to `file_path` is
333-
// found. `gix_diff::tree` converts `Cancel` into `Err(...)` which is why we ignore its return
334-
// value here. I don’t know whether this has the potential to hide bugs.
335-
let _ = gix_diff::tree(parent_tree_iter, tree_iter, state, &odb, &mut recorder);
331+
let result = gix_diff::tree(parent_tree_iter, tree_iter, state, &odb, &mut recorder);
336332
stats.trees_diffed += 1;
337333

338-
Ok(recorder.change)
334+
match result {
335+
// `recorder` cancels the traversal by returning `Cancel` when a change to `file_path` is
336+
// found. `gix_diff::tree` converts `Cancel` into `Err(Cancelled)` which is why we match on
337+
// `Err(Cancelled)` in addition to `Ok`.
338+
Ok(_) | Err(gix_diff::tree::Error::Cancelled) => Ok(recorder.change),
339+
Err(error) => Err(Error::DiffTree(error)),
340+
}
339341
}
340342

341343
// TODO

0 commit comments

Comments
 (0)