error("unable to unlink %s", pathname);
        }
        pathname[len] = 0;
-       if (!rmdir(pathname))
-               mkdir(pathname, 0777);
+       rmdir(pathname);
 }
 
 static void prune_packed_objects(void)
 {
        int i;
 
+       setup_git_directory();
+
        for (i = 1; i < argc; i++) {
                const char *arg = argv[i];
 
                /* Handle arguments here .. */
                usage(prune_packed_usage);
        }
+       sync();
        prune_packed_objects();
        return 0;
 }