aboutsummaryrefslogtreecommitdiff
path: root/src/nix/why-depends.cc
diff options
context:
space:
mode:
authorCarlo Nucera <carlo.nucera@protonmail.com>2020-07-15 17:19:56 -0400
committerCarlo Nucera <carlo.nucera@protonmail.com>2020-07-15 17:21:01 -0400
commitd0905623488ca97feeb28ebd9817af6270a53c48 (patch)
treebe3504d2c37bc65df0f80dc358bbec49c217e7bf /src/nix/why-depends.cc
parent44157653850ce18536f837d7ed53521d61a238a1 (diff)
parent36a124260361ba8dfa43bf43a067dcc48064c93f (diff)
Merge branch 'master' of github.com:NixOS/nix into hash-always-has-type
Diffstat (limited to 'src/nix/why-depends.cc')
-rw-r--r--src/nix/why-depends.cc8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/nix/why-depends.cc b/src/nix/why-depends.cc
index 167c974ee..49da01c0a 100644
--- a/src/nix/why-depends.cc
+++ b/src/nix/why-depends.cc
@@ -106,7 +106,11 @@ struct CmdWhyDepends : SourceExprCommand
std::map<StorePath, Node> graph;
for (auto & path : closure)
- graph.emplace(path, Node { .path = path, .refs = store->queryPathInfo(path)->references });
+ graph.emplace(path, Node {
+ .path = path,
+ .refs = store->queryPathInfo(path)->references,
+ .dist = path == dependencyPath ? 0 : inf
+ });
// Transpose the graph.
for (auto & node : graph)
@@ -115,8 +119,6 @@ struct CmdWhyDepends : SourceExprCommand
/* Run Dijkstra's shortest path algorithm to get the distance
of every path in the closure to 'dependency'. */
- graph.emplace(dependencyPath, Node { .path = dependencyPath, .dist = 0 });
-
std::priority_queue<Node *> queue;
queue.push(&graph.at(dependencyPath));