From 3c0e67bbc5f7c3849919735db4bfd7e66190f80c Mon Sep 17 00:00:00 2001 From: Gavin Mak Date: Wed, 14 Jan 2026 22:14:28 +0000 Subject: [PATCH] manifest_xml: prevent extend-project from inheriting local groups When extending a project in a local manifest, the project inherits the `local:` group. This causes the superproject override logic (which omits projects with `local:` groups) to incorrectly exclude the project from the override manifest. This leads to "extend-project element specifies non-existent project" errors during sync reload. Fix this by stripping `local:` groups from extended projects, ensuring they remain visible to superproject overrides while still allowing other inherited groups to persist. Bug: 470374343 Change-Id: I1a057ebffebc11a19dc14dde7cc13b9f18cdd0a3 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/543222 Reviewed-by: Peter Kjellerstedt Reviewed-by: Mike Frysinger Tested-by: Gavin Mak Commit-Queue: Gavin Mak --- manifest_xml.py | 8 ++++++++ tests/test_manifest_xml.py | 27 +++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) 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."""