diff --git a/manifest_xml.py b/manifest_xml.py
index 7987061d6..6989aad53 100644
--- a/manifest_xml.py
+++ b/manifest_xml.py
@@ -1487,6 +1487,14 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md
continue
if groups:
p.groups |= groups
+ # Drop local groups so we don't mistakenly omit this
+ # project from the superproject override manifest.
+ p.groups = {
+ g
+ for g in p.groups
+ if not g.startswith(LOCAL_MANIFEST_GROUP_PREFIX)
+ }
+
if revision:
if base_revision:
if p.revisionExpr != base_revision:
diff --git a/tests/test_manifest_xml.py b/tests/test_manifest_xml.py
index 039921f65..97fea3da3 100644
--- a/tests/test_manifest_xml.py
+++ b/tests/test_manifest_xml.py
@@ -549,6 +549,33 @@ class IncludeElementTests(ManifestParseTestCase):
# Check project has set group via extend-project element.
self.assertIn("eg1", proj.groups)
+ def test_extend_project_does_not_inherit_local_groups(self):
+ """Check that extend-project does not inherit local groups."""
+ root_m = self.manifest_dir / "root.xml"
+ root_m.write_text(
+ """
+
+
+
+
+
+
+"""
+ )
+ (self.manifest_dir / "man1.xml").write_text(
+ """
+
+
+
+"""
+ )
+ include_m = manifest_xml.XmlManifest(str(self.repodir), str(root_m))
+ proj = include_m.projects[0]
+
+ self.assertIn("g1", proj.groups)
+ self.assertNotIn("local:g2", proj.groups)
+ self.assertIn("g3", proj.groups)
+
def test_allow_bad_name_from_user(self):
"""Check handling of bad name attribute from the user's input."""