Skip to content

Commit c272079

Browse files
authored
Merge pull request #6072 from Ma27/fix-nix-why-depends-non-precise
nix/why-depends: fix output when not using `--precise`
2 parents e85d565 + 5b58657 commit c272079

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/nix/why-depends.cc

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -171,20 +171,14 @@ struct CmdWhyDepends : SourceExprCommand
171171
node.visited ? "\e[38;5;244m" : "",
172172
firstPad != "" ? "" : "",
173173
pathS);
174-
} else {
175-
logger->cout("%s%s%s%s" ANSI_NORMAL,
176-
firstPad,
177-
node.visited ? "\e[38;5;244m" : "",
178-
firstPad != "" ? treeLast : "",
179-
pathS);
180174
}
181175

182176
if (node.path == dependencyPath && !all
183177
&& packagePath != dependencyPath)
184178
throw BailOut();
185179

186180
if (node.visited) return;
187-
node.visited = true;
181+
if (precise) node.visited = true;
188182

189183
/* Sort the references by distance to `dependency` to
190184
ensure that the shortest path is printed first. */
@@ -267,6 +261,16 @@ struct CmdWhyDepends : SourceExprCommand
267261
if (!all) break;
268262
}
269263

264+
if (!precise) {
265+
auto pathS = store->printStorePath(ref.second->path);
266+
logger->cout("%s%s%s%s" ANSI_NORMAL,
267+
firstPad,
268+
ref.second->visited ? "\e[38;5;244m" : "",
269+
last ? treeLast : treeConn,
270+
pathS);
271+
node.visited = true;
272+
}
273+
270274
printNode(*ref.second,
271275
tailPad + (last ? treeNull : treeLine),
272276
tailPad + (last ? treeNull : treeLine));
@@ -275,6 +279,9 @@ struct CmdWhyDepends : SourceExprCommand
275279

276280
RunPager pager;
277281
try {
282+
if (!precise) {
283+
logger->cout("%s", store->printStorePath(graph.at(packagePath).path));
284+
}
278285
printNode(graph.at(packagePath), "", "");
279286
} catch (BailOut & ) { }
280287
}

0 commit comments

Comments
 (0)