about summary refs log tree commit diff
path: root/src/nix-store/nix-store.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2019-03-14T12·59+0100
committerEelco Dolstra <edolstra@gmail.com>2019-03-14T12·59+0100
commit86f3b94c8c28defd7402245d60af15ce429986ff (patch)
tree8350e5af881796c0ac7fd29fa17ea9e6cd3cbb5b /src/nix-store/nix-store.cc
parent578ed7a259ddf7a85c85fe4e0200179ae908171e (diff)
nix-store --gc --print-roots: Sort output
Diffstat (limited to 'src/nix-store/nix-store.cc')
-rw-r--r--src/nix-store/nix-store.cc6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/nix-store/nix-store.cc b/src/nix-store/nix-store.cc
index 6f315e5093da..f324056bb3a1 100644
--- a/src/nix-store/nix-store.cc
+++ b/src/nix-store/nix-store.cc
@@ -592,9 +592,13 @@ static void opGC(Strings opFlags, Strings opArgs)
 
     if (printRoots) {
         Roots roots = store->findRoots(false);
+        std::set<std::pair<Path, Path>> roots2;
+        // Transpose and sort the roots.
         for (auto & [target, links] : roots)
             for (auto & link : links)
-                cout << link << " -> " << target << std::endl;
+                roots2.emplace(link, target);
+        for (auto & [link, target] : roots2)
+            std::cout << link << " -> " << target << "\n";
     }
 
     else {