superproject: Inherit --no-use-superproject with --mirror option.
+ Similar to opt.archive, gave an error if --mirror option is
  used with --use-superproject.
+ Defaulted to --no-use-superproject if manifest is a mirror or
  archive (similar to error at line# 1067).

+ run_tests
+ flake8 (will fix known errors in another CL).

$ repo_dev init -u sso:// --use-superproject --mirror
Usage: repo init [options] [manifest url] error: --mirror and --use-superproject cannot be used together.

+ repo init and repo sync with --mirror and without --mirror
  $ repo_dev init -u
  $ repo_dev sync
    ...superproject.git: Initial setup for superproject completed.

+ With --mirror option, verfied there are no exceptions in

Bug: [google internal] b/206537893
Change-Id: I059f20e76f0ab36f0587f29779bb53ede4663bd4
Reviewed-by: Mike Frysinger <>
Tested-by: Raman Tenneti <>
diff --git a/subcmds/ b/subcmds/
index a3f3241..1fbe465 100644
--- a/subcmds/
+++ b/subcmds/
@@ -478,8 +478,13 @@
     # Check this here, else manifest will be tagged "not new" and init won't be
     # possible anymore without removing the .repo/manifests directory.
-    if opt.archive and opt.mirror:
-      self.OptionParser.error('--mirror and --archive cannot be used together.')
+    if opt.mirror:
+      if opt.archive:
+        self.OptionParser.error('--mirror and --archive cannot be used '
+                                'together.')
+      if opt.use_superproject is not None:
+        self.OptionParser.error('--mirror and --use-superproject cannot be '
+                                'used together.')
     if opt.standalone_manifest and (
         opt.manifest_branch or opt.manifest_name != 'default.xml'):
diff --git a/subcmds/ b/subcmds/
index 1d778e1..ee7e4a8 100644
--- a/subcmds/
+++ b/subcmds/
@@ -986,6 +986,10 @@
     load_local_manifests = not self.manifest.HasLocalManifests
     use_superproject = git_superproject.UseSuperproject(opt, self.manifest)
+    if self.manifest.IsMirror or self.manifest.IsArchive:
+      # Don't use superproject, because we have no working tree.
+      use_superproject = False
+      print('Defaulting to no-use-superproject because there is no working tree.')
     superproject_logging_data = {
         'superproject': use_superproject,
         'haslocalmanifests': bool(self.manifest.HasLocalManifests),