1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-08 02:43:54 +02:00

Merge pull request #8786 from Ma27/fix-why-depends-precise

nix/why-depends: fix output of `--precise`
This commit is contained in:
Eelco Dolstra 2023-08-07 19:32:49 +02:00 committed by GitHub
commit 5624777988
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 5 deletions

View file

@ -239,7 +239,7 @@ struct CmdWhyDepends : SourceExprCommand, MixOperateOnOptions
if (pos != std::string::npos) {
size_t margin = 32;
auto pos2 = pos >= margin ? pos - margin : 0;
hits[hash].emplace_back(fmt("%s: …%s…\n",
hits[hash].emplace_back(fmt("%s: …%s…",
p2,
hilite(filterPrintable(
std::string(contents, pos2, pos - pos2 + hash.size() + margin)),
@ -255,7 +255,7 @@ struct CmdWhyDepends : SourceExprCommand, MixOperateOnOptions
for (auto & hash : hashes) {
auto pos = target.find(hash);
if (pos != std::string::npos)
hits[hash].emplace_back(fmt("%s -> %s\n", p2,
hits[hash].emplace_back(fmt("%s -> %s", p2,
hilite(target, pos, StorePath::HashLen, getColour(hash))));
}
}
@ -272,9 +272,9 @@ struct CmdWhyDepends : SourceExprCommand, MixOperateOnOptions
for (auto & hit : hits[hash]) {
bool first = hit == *hits[hash].begin();
std::cout << tailPad
<< (first ? (last ? treeLast : treeConn) : (last ? treeNull : treeLine))
<< hit;
logger->cout("%s%s%s", tailPad,
(first ? (last ? treeLast : treeConn) : (last ? treeNull : treeLine)),
hit);
if (!all) break;
}