about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libstore/gc.cc5
-rw-r--r--src/libstore/store-api.hh5
-rw-r--r--src/nix-store/nix-store.cc23
3 files changed, 16 insertions, 17 deletions
diff --git a/src/libstore/gc.cc b/src/libstore/gc.cc
index 34b5ff267f8b..d3cac06e4c5a 100644
--- a/src/libstore/gc.cc
+++ b/src/libstore/gc.cc
@@ -614,11 +614,6 @@ void LocalStore::collectGarbage(const GCOptions & options, GCResults & results)
     if (!options.ignoreLiveness)
         addAdditionalRoots(state.roots);
 
-    if (options.action == GCOptions::gcReturnRoots) {
-        results.paths = state.roots;
-        return;
-    }
-
     /* Read the temporary roots.  This acquires read locks on all
        per-process temporary root files.  So after this point no paths
        can be added to the set of temporary roots. */
diff --git a/src/libstore/store-api.hh b/src/libstore/store-api.hh
index d827dff84124..101215707f37 100644
--- a/src/libstore/store-api.hh
+++ b/src/libstore/store-api.hh
@@ -22,10 +22,6 @@ struct GCOptions
 {
     /* Garbage collector operation:
 
-       - `gcReturnRoots': find and return the set of roots for the
-         garbage collector.  These are the store paths symlinked to in
-         the `gcroots' directory.
-
        - `gcReturnLive': return the set of paths reachable from
          (i.e. in the closure of) the roots.
 
@@ -38,7 +34,6 @@ struct GCOptions
           `pathsToDelete', insofar as they are not reachable.
     */
     typedef enum {
-        gcReturnRoots,
         gcReturnLive,
         gcReturnDead,
         gcDeleteDead,
diff --git a/src/nix-store/nix-store.cc b/src/nix-store/nix-store.cc
index 3740d0bf9546..b951393092b9 100644
--- a/src/nix-store/nix-store.cc
+++ b/src/nix-store/nix-store.cc
@@ -520,6 +520,7 @@ struct PrintFreed
 
 static void opGC(Strings opFlags, Strings opArgs)
 {
+    bool printRoots = false;
     GCOptions options;
     options.action = GCOptions::gcDeleteDead;
     
@@ -527,7 +528,7 @@ static void opGC(Strings opFlags, Strings opArgs)
     
     /* Do what? */
     foreach (Strings::iterator, i, opFlags)
-        if (*i == "--print-roots") options.action = GCOptions::gcReturnRoots;
+        if (*i == "--print-roots") printRoots = true;
         else if (*i == "--print-live") options.action = GCOptions::gcReturnLive;
         else if (*i == "--print-dead") options.action = GCOptions::gcReturnDead;
         else if (*i == "--delete") options.action = GCOptions::gcDeleteDead;
@@ -539,13 +540,21 @@ static void opGC(Strings opFlags, Strings opArgs)
         else throw UsageError(format("bad sub-operation `%1%' in GC") % *i);
 
     if (!opArgs.empty()) throw UsageError("no arguments expected");
-    
-    PrintFreed freed(options.action == GCOptions::gcDeleteDead, results);
-    store->collectGarbage(options, results);
 
-    if (options.action != GCOptions::gcDeleteDead)
-        foreach (PathSet::iterator, i, results.paths)
-            cout << *i << std::endl;
+    if (printRoots) {
+        Roots roots = store->findRoots();
+        foreach (Roots::iterator, i, roots)
+            cout << i->first << " -> " << i->second << std::endl;
+    }
+
+    else {
+        PrintFreed freed(options.action == GCOptions::gcDeleteDead, results);
+        store->collectGarbage(options, results);
+
+        if (options.action != GCOptions::gcDeleteDead)
+            foreach (PathSet::iterator, i, results.paths)
+                cout << *i << std::endl;
+    }
 }