list: add option to show non-checkedout projects too

Currently, list only shows projects that exist in the checkout, and
doesn't offer any way to list all projects in the manifest (based on
the current settings, or on the options passed to list).  This seems
to be the opposite of what (at least some) users expect, so let's
add an option to show all of them regardless of checkout state.

Change-Id: I94bbdc5bd0ff2a411704fa215e7fc2b60fa3360e
Reviewed-by: Raman Tenneti <>
Tested-by: Mike Frysinger <>
diff --git a/subcmds/ b/subcmds/
index 7825dee..0dfaf31 100644
--- a/subcmds/
+++ b/subcmds/
@@ -25,6 +25,11 @@
   helpDescription = """
 List all projects; pass '.' to list the project for the cwd.
+By default, only projects that currently exist in the checkout are shown.  If
+you to list all projects (using the specified filter settings), use the --all
+option.  If you want to show all projects regardless of the manifest groups,
+then also pass --groups all.
 This is similar to running: repo forall -c 'echo "$REPO_PATH : $REPO_PROJECT"'.
@@ -35,6 +40,9 @@
     p.add_option('-g', '--groups',
                  help="Filter the project list based on the groups the project is in")
+    p.add_option('-a', '--all',
+                 action='store_true',
+                 help='Show projects regardless of checkout state')
     p.add_option('-f', '--fullpath',
                  dest='fullpath', action='store_true',
                  help="Display the full work tree path instead of the relative path")
@@ -61,7 +69,7 @@
       args: Positional args.  Can be a list of projects to list, or empty.
     if not opt.regex:
-      projects = self.GetProjects(args, groups=opt.groups)
+      projects = self.GetProjects(args, groups=opt.groups, missing_ok=opt.all)
       projects = self.FindProjects(args)
@@ -79,5 +87,6 @@
         lines.append("%s : %s" % (_getpath(project),
-    lines.sort()
-    print('\n'.join(lines))
+    if lines:
+      lines.sort()
+      print('\n'.join(lines))