diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2017-09-14 11:17:32 +0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2017-09-14 11:17:32 +0200 |
commit | 1c58ad2ffa698d17b7be56eab69a40ace64d0e21 (patch) | |
tree | cb2213c04416de639d86600d357d2c6b9fb9d6fc /src/nix/why-depends.cc | |
parent | 359ede1d729964862d823d54e416d36291a02d79 (diff) |
nix why-depends: Fix showing self-references
Diffstat (limited to 'src/nix/why-depends.cc')
-rw-r--r-- | src/nix/why-depends.cc | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/nix/why-depends.cc b/src/nix/why-depends.cc index a6750ac95..f31469cbc 100644 --- a/src/nix/why-depends.cc +++ b/src/nix/why-depends.cc @@ -1,6 +1,4 @@ #include "command.hh" -#include "common-args.hh" -#include "shared.hh" #include "store-api.hh" #include "progress-bar.hh" #include "fs-accessor.hh" @@ -59,9 +57,17 @@ struct CmdWhyDepends : SourceExprCommand { return { Example{ - "To show which files in Hello's closure depend on Glibc:", + "To show one path through the dependency graph leading from Hello to Glibc:", "nix why-depends nixpkgs.hello nixpkgs.glibc" }, + Example{ + "To show all files and paths in the dependency graph leading from Thunderbird to libX11:", + "nix why-depends --all nixpkgs.thunderbird nixpkgs.xorg.libX11" + }, + Example{ + "To show why Glibc depends on itself:", + "nix why-depends nixpkgs.glibc nixpkgs.glibc" + }, }; } @@ -141,9 +147,9 @@ struct CmdWhyDepends : SourceExprCommand and `dependency`. */ std::function<void(Node &, const string &, const string &)> printNode; - const string treeConn = "├───"; - const string treeLast = "└───"; - const string treeLine = "│ "; + const string treeConn = "╠═══"; + const string treeLast = "╚═══"; + const string treeLine = "║ "; const string treeNull = " "; struct BailOut { }; @@ -156,7 +162,9 @@ struct CmdWhyDepends : SourceExprCommand firstPad != "" ? "=> " : "", node.path); - if (node.path == dependencyPath && !all) throw BailOut(); + if (node.path == dependencyPath && !all + && packagePath != dependencyPath) + throw BailOut(); if (node.visited) return; node.visited = true; @@ -167,7 +175,7 @@ struct CmdWhyDepends : SourceExprCommand std::set<std::string> hashes; for (auto & ref : node.refs) { - if (ref == node.path) continue; + if (ref == node.path && packagePath != dependencyPath) continue; auto & node2 = graph.at(ref); if (node2.dist == inf) continue; refs.emplace(node2.dist, &node2); |