From 3194e3b6f479e28515c8a5db1e0b33599e76c300 Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Sun, 18 Jan 2026 19:20:35 +0100 Subject: [PATCH] nix-store: don't print to stdout from printTree print into a provided stream instead. Change-Id: I52495154163e40d05b6897aa129eb9b3d81348dc --- lix/legacy/nix-store.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lix/legacy/nix-store.cc b/lix/legacy/nix-store.cc index 6672b41bb..6427e9a80 100644 --- a/lix/legacy/nix-store.cc +++ b/lix/legacy/nix-store.cc @@ -288,6 +288,7 @@ try { graph. Topological sorting is used to keep the tree relatively flat. */ static void printTree( + std::ostream & ostream, std::shared_ptr store, AsyncIoRoot & aio, const StorePath & path, @@ -297,11 +298,11 @@ static void printTree( ) { if (!done.insert(path).second) { - cout << fmt("%s%s [...]\n", firstPad, store->printStorePath(path)); + ostream << fmt("%s%s [...]\n", firstPad, store->printStorePath(path)); return; } - cout << fmt("%s%s\n", firstPad, store->printStorePath(path)); + ostream << fmt("%s%s\n", firstPad, store->printStorePath(path)); auto info = aio.blockOn(store->queryPathInfo(path)); @@ -315,6 +316,7 @@ static void printTree( for (const auto &[n, i] : enumerate(sorted)) { bool last = n + 1 == sorted.size(); printTree( + ostream, store, aio, i, @@ -477,7 +479,7 @@ opQuery(std::shared_ptr store, AsyncIoRoot & aio, Strings opFlags, String case qTree: { StorePathSet done; for (auto & i : opArgs) - printTree(store, aio, store->followLinksToStorePath(i), "", "", done); + printTree(std::cout, store, aio, store->followLinksToStorePath(i), "", "", done); break; }