Skip to content

Commit

Permalink
Annotate duplicate entries with a (*)
Browse files Browse the repository at this point in the history
Rather than re-traverse the entries, which can lead to [pathological
cases] of recursion, keep track of which PackageIds have been shown.
When encountering a duplicate PackageId, indicate this with "(*)" as
"cargo tree" does, and return early.

[pathological cases]: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1052650
  • Loading branch information
jamessan committed Nov 25, 2023
1 parent 956c9ab commit 3b65db9
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,13 @@ fn print_package<'a>(
Prefix::None => {}
}

if !all && visited_deps.contains(&package.id) {
println!("{} (*)", format.display(package));
return;
}

visited_deps.insert(&package.id);

println!("{}", format.display(package));

if package.in_debian() {
Expand Down

0 comments on commit 3b65db9

Please sign in to comment.