about summary refs log tree commit diff
path: root/src/nix-store/main.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/nix-store/main.cc')
-rw-r--r--src/nix-store/main.cc20
1 files changed, 5 insertions, 15 deletions
diff --git a/src/nix-store/main.cc b/src/nix-store/main.cc
index 3edcff7eeef0..d473475b821a 100644
--- a/src/nix-store/main.cc
+++ b/src/nix-store/main.cc
@@ -38,9 +38,7 @@ static Path followSymlinks(Path & path)
     while (!isStorePath(path)) {
         if (!isLink(path)) return path;
         string target = readLink(path);
-        path = canonPath(string(target, 0, 1) == "/"
-            ? target
-            : path + "/" + target);
+        path = absPath(target, dirOf(path));
     }
     return path;
 }
@@ -308,27 +306,19 @@ static void opIsValid(Strings opFlags, Strings opArgs)
 
 static void opGC(Strings opFlags, Strings opArgs)
 {
-    GCAction action;
+    GCAction action = gcDeleteDead;
     
     /* Do what? */
     for (Strings::iterator i = opFlags.begin();
          i != opFlags.end(); ++i)
-        if (*i == "--print-live") action = gcReturnLive;
+        if (*i == "--print-roots") action = gcReturnRoots;
+        else if (*i == "--print-live") action = gcReturnLive;
         else if (*i == "--print-dead") action = gcReturnDead;
         else if (*i == "--delete") action = gcDeleteDead;
         else throw UsageError(format("bad sub-operation `%1%' in GC") % *i);
 
-    /* Read the roots. */
-    PathSet roots;
-    while (1) {
-        Path root;
-        getline(cin, root);
-        if (cin.eof()) break;
-        roots.insert(root);
-    }
-
     PathSet result;
-    collectGarbage(roots, action, result);
+    collectGarbage(action, result);
 
     if (action != gcDeleteDead) {
         for (PathSet::iterator i = result.begin(); i != result.end(); ++i)