diff options
| author | Jacky Liu <qsliu@google.com> | 2026-03-16 13:07:39 +0800 |
|---|---|---|
| committer | LUCI <gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2026-03-18 21:03:07 -0700 |
| commit | 0176586544d36d2902d6b8442ea4dc78e7921b8e (patch) | |
| tree | e3e5c36e9c36bf8849936a45858d02f098f872ea | |
| parent | 582804a59ef11a8e545ace2efb774df5dcbe93ee (diff) | |
| download | git-repo-main.tar.gz | |
Use git_superproject.UseSuperproject() everywheremain
Currently somewhere use git_superproject.UseSuperproject(), which checks
both the manifest config and user's config, and otherwhere use
manifest.manifestProject.use_superproject, which only checks the
manifest config. This causes Inconsistent behaviors for users who do not
set --use-superproject when doing repo init but have
repo.superprojectChoice in their git config.
Replace where using manifest.manifestProject.use_superproject with
git_superproject.UseSuperproject() to respect user's config and avoid
inconsistency.
Bug: 454514213
Change-Id: I1f734235cdd67b8a6915f1d05967d1aaa4d03f2a
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/561801
Commit-Queue: Jacky Liu <qsliu@google.com>
Reviewed-by: Mike Frysinger <vapier@google.com>
Tested-by: Jacky Liu <qsliu@google.com>
| -rw-r--r-- | project.py | 31 | ||||
| -rw-r--r-- | subcmds/sync.py | 4 | ||||
| -rw-r--r-- | subcmds/upload.py | 3 |
3 files changed, 30 insertions, 8 deletions
| @@ -28,7 +28,7 @@ import sys | |||
| 28 | import tarfile | 28 | import tarfile |
| 29 | import tempfile | 29 | import tempfile |
| 30 | import time | 30 | import time |
| 31 | from typing import List, NamedTuple | 31 | from typing import List, NamedTuple, Optional |
| 32 | import urllib.parse | 32 | import urllib.parse |
| 33 | 33 | ||
| 34 | from color import Coloring | 34 | from color import Coloring |
| @@ -1245,6 +1245,7 @@ class Project: | |||
| 1245 | verbose=False, | 1245 | verbose=False, |
| 1246 | output_redir=None, | 1246 | output_redir=None, |
| 1247 | is_new=None, | 1247 | is_new=None, |
| 1248 | use_superproject=None, | ||
| 1248 | current_branch_only=None, | 1249 | current_branch_only=None, |
| 1249 | force_sync=False, | 1250 | force_sync=False, |
| 1250 | clone_bundle=True, | 1251 | clone_bundle=True, |
| @@ -1399,7 +1400,9 @@ class Project: | |||
| 1399 | if not ( | 1400 | if not ( |
| 1400 | optimized_fetch | 1401 | optimized_fetch |
| 1401 | and IsId(self.revisionExpr) | 1402 | and IsId(self.revisionExpr) |
| 1402 | and self._CheckForImmutableRevision() | 1403 | and self._CheckForImmutableRevision( |
| 1404 | use_superproject=use_superproject | ||
| 1405 | ) | ||
| 1403 | ): | 1406 | ): |
| 1404 | remote_fetched = True | 1407 | remote_fetched = True |
| 1405 | try: | 1408 | try: |
| @@ -1409,6 +1412,7 @@ class Project: | |||
| 1409 | verbose=verbose, | 1412 | verbose=verbose, |
| 1410 | output_redir=output_redir, | 1413 | output_redir=output_redir, |
| 1411 | alt_dir=alt_dir, | 1414 | alt_dir=alt_dir, |
| 1415 | use_superproject=use_superproject, | ||
| 1412 | current_branch_only=current_branch_only, | 1416 | current_branch_only=current_branch_only, |
| 1413 | tags=tags, | 1417 | tags=tags, |
| 1414 | prune=prune, | 1418 | prune=prune, |
| @@ -2397,7 +2401,9 @@ class Project: | |||
| 2397 | 2401 | ||
| 2398 | return None | 2402 | return None |
| 2399 | 2403 | ||
| 2400 | def _CheckForImmutableRevision(self): | 2404 | def _CheckForImmutableRevision( |
| 2405 | self, use_superproject: Optional[bool] = None | ||
| 2406 | ) -> bool: | ||
| 2401 | try: | 2407 | try: |
| 2402 | # if revision (sha or tag) is not present then following function | 2408 | # if revision (sha or tag) is not present then following function |
| 2403 | # throws an error. | 2409 | # throws an error. |
| @@ -2405,7 +2411,9 @@ class Project: | |||
| 2405 | upstream_rev = None | 2411 | upstream_rev = None |
| 2406 | 2412 | ||
| 2407 | # Only check upstream when using superproject. | 2413 | # Only check upstream when using superproject. |
| 2408 | if self.upstream and self.manifest.manifestProject.use_superproject: | 2414 | if self.upstream and git_superproject.UseSuperproject( |
| 2415 | use_superproject, self.manifest | ||
| 2416 | ): | ||
| 2409 | upstream_rev = self.GetRemote().ToLocal(self.upstream) | 2417 | upstream_rev = self.GetRemote().ToLocal(self.upstream) |
| 2410 | revs.append(upstream_rev) | 2418 | revs.append(upstream_rev) |
| 2411 | 2419 | ||
| @@ -2419,7 +2427,9 @@ class Project: | |||
| 2419 | 2427 | ||
| 2420 | # Only verify upstream relationship for superproject scenarios | 2428 | # Only verify upstream relationship for superproject scenarios |
| 2421 | # without affecting plain usage. | 2429 | # without affecting plain usage. |
| 2422 | if self.upstream and self.manifest.manifestProject.use_superproject: | 2430 | if self.upstream and git_superproject.UseSuperproject( |
| 2431 | use_superproject, self.manifest | ||
| 2432 | ): | ||
| 2423 | self.bare_git.merge_base( | 2433 | self.bare_git.merge_base( |
| 2424 | "--is-ancestor", | 2434 | "--is-ancestor", |
| 2425 | self.revisionExpr, | 2435 | self.revisionExpr, |
| @@ -2450,6 +2460,7 @@ class Project: | |||
| 2450 | def _RemoteFetch( | 2460 | def _RemoteFetch( |
| 2451 | self, | 2461 | self, |
| 2452 | name=None, | 2462 | name=None, |
| 2463 | use_superproject=None, | ||
| 2453 | current_branch_only=False, | 2464 | current_branch_only=False, |
| 2454 | initial=False, | 2465 | initial=False, |
| 2455 | quiet=False, | 2466 | quiet=False, |
| @@ -2489,7 +2500,9 @@ class Project: | |||
| 2489 | tag_name = self.upstream[len(R_TAGS) :] | 2500 | tag_name = self.upstream[len(R_TAGS) :] |
| 2490 | 2501 | ||
| 2491 | if is_sha1 or tag_name is not None: | 2502 | if is_sha1 or tag_name is not None: |
| 2492 | if self._CheckForImmutableRevision(): | 2503 | if self._CheckForImmutableRevision( |
| 2504 | use_superproject=use_superproject | ||
| 2505 | ): | ||
| 2493 | if verbose: | 2506 | if verbose: |
| 2494 | print( | 2507 | print( |
| 2495 | "Skipped fetching project %s (already have " | 2508 | "Skipped fetching project %s (already have " |
| @@ -2809,7 +2822,9 @@ class Project: | |||
| 2809 | # We just synced the upstream given branch; verify we | 2822 | # We just synced the upstream given branch; verify we |
| 2810 | # got what we wanted, else trigger a second run of all | 2823 | # got what we wanted, else trigger a second run of all |
| 2811 | # refs. | 2824 | # refs. |
| 2812 | if not self._CheckForImmutableRevision(): | 2825 | if not self._CheckForImmutableRevision( |
| 2826 | use_superproject=use_superproject | ||
| 2827 | ): | ||
| 2813 | # Sync the current branch only with depth set to None. | 2828 | # Sync the current branch only with depth set to None. |
| 2814 | # We always pass depth=None down to avoid infinite recursion. | 2829 | # We always pass depth=None down to avoid infinite recursion. |
| 2815 | return self._RemoteFetch( | 2830 | return self._RemoteFetch( |
| @@ -2817,6 +2832,7 @@ class Project: | |||
| 2817 | quiet=quiet, | 2832 | quiet=quiet, |
| 2818 | verbose=verbose, | 2833 | verbose=verbose, |
| 2819 | output_redir=output_redir, | 2834 | output_redir=output_redir, |
| 2835 | use_superproject=use_superproject, | ||
| 2820 | current_branch_only=current_branch_only and depth, | 2836 | current_branch_only=current_branch_only and depth, |
| 2821 | initial=False, | 2837 | initial=False, |
| 2822 | alt_dir=alt_dir, | 2838 | alt_dir=alt_dir, |
| @@ -4827,6 +4843,7 @@ class ManifestProject(MetaProject): | |||
| 4827 | quiet=not verbose, | 4843 | quiet=not verbose, |
| 4828 | verbose=verbose, | 4844 | verbose=verbose, |
| 4829 | clone_bundle=clone_bundle, | 4845 | clone_bundle=clone_bundle, |
| 4846 | use_superproject=use_superproject, | ||
| 4830 | current_branch_only=current_branch_only, | 4847 | current_branch_only=current_branch_only, |
| 4831 | tags=tags, | 4848 | tags=tags, |
| 4832 | submodules=submodules, | 4849 | submodules=submodules, |
diff --git a/subcmds/sync.py b/subcmds/sync.py index 89b58e6a..03c0eba6 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py | |||
| @@ -808,6 +808,7 @@ later is required to fix a server side protocol bug. | |||
| 808 | quiet=opt.quiet, | 808 | quiet=opt.quiet, |
| 809 | verbose=opt.verbose, | 809 | verbose=opt.verbose, |
| 810 | output_redir=buf, | 810 | output_redir=buf, |
| 811 | use_superproject=opt.use_superproject, | ||
| 811 | current_branch_only=cls._GetCurrentBranchOnly( | 812 | current_branch_only=cls._GetCurrentBranchOnly( |
| 812 | opt, project.manifest | 813 | opt, project.manifest |
| 813 | ), | 814 | ), |
| @@ -1499,6 +1500,7 @@ later is required to fix a server side protocol bug. | |||
| 1499 | quiet=opt.quiet, | 1500 | quiet=opt.quiet, |
| 1500 | verbose=opt.verbose, | 1501 | verbose=opt.verbose, |
| 1501 | output_redir=buf, | 1502 | output_redir=buf, |
| 1503 | use_superproject=opt.use_superproject, | ||
| 1502 | current_branch_only=self._GetCurrentBranchOnly( | 1504 | current_branch_only=self._GetCurrentBranchOnly( |
| 1503 | opt, manifest | 1505 | opt, manifest |
| 1504 | ), | 1506 | ), |
| @@ -1830,6 +1832,7 @@ later is required to fix a server side protocol bug. | |||
| 1830 | quiet=not opt.verbose, | 1832 | quiet=not opt.verbose, |
| 1831 | output_redir=buf, | 1833 | output_redir=buf, |
| 1832 | verbose=opt.verbose, | 1834 | verbose=opt.verbose, |
| 1835 | use_superproject=opt.use_superproject, | ||
| 1833 | current_branch_only=self._GetCurrentBranchOnly( | 1836 | current_branch_only=self._GetCurrentBranchOnly( |
| 1834 | opt, mp.manifest | 1837 | opt, mp.manifest |
| 1835 | ), | 1838 | ), |
| @@ -2356,6 +2359,7 @@ later is required to fix a server side protocol bug. | |||
| 2356 | quiet=opt.quiet, | 2359 | quiet=opt.quiet, |
| 2357 | verbose=opt.verbose, | 2360 | verbose=opt.verbose, |
| 2358 | output_redir=network_output_capture, | 2361 | output_redir=network_output_capture, |
| 2362 | use_superproject=opt.use_superproject, | ||
| 2359 | current_branch_only=cls._GetCurrentBranchOnly( | 2363 | current_branch_only=cls._GetCurrentBranchOnly( |
| 2360 | opt, project.manifest | 2364 | opt, project.manifest |
| 2361 | ), | 2365 | ), |
diff --git a/subcmds/upload.py b/subcmds/upload.py index 4f817ddf..60bbb006 100644 --- a/subcmds/upload.py +++ b/subcmds/upload.py | |||
| @@ -27,6 +27,7 @@ from error import SilentRepoExitError | |||
| 27 | from error import UploadError | 27 | from error import UploadError |
| 28 | from git_command import GitCommand | 28 | from git_command import GitCommand |
| 29 | from git_refs import R_HEADS | 29 | from git_refs import R_HEADS |
| 30 | import git_superproject | ||
| 30 | from hooks import RepoHook | 31 | from hooks import RepoHook |
| 31 | from project import ReviewableBranch | 32 | from project import ReviewableBranch |
| 32 | from repo_logging import RepoLogger | 33 | from repo_logging import RepoLogger |
| @@ -627,7 +628,7 @@ Gerrit Code Review: https://www.gerritcodereview.com/ | |||
| 627 | # If using superproject, add the root repo as a push option. | 628 | # If using superproject, add the root repo as a push option. |
| 628 | manifest = branch.project.manifest | 629 | manifest = branch.project.manifest |
| 629 | push_options = list(opt.push_options) | 630 | push_options = list(opt.push_options) |
| 630 | if manifest.manifestProject.use_superproject: | 631 | if git_superproject.UseSuperproject(None, manifest): |
| 631 | sp = manifest.superproject | 632 | sp = manifest.superproject |
| 632 | if sp: | 633 | if sp: |
| 633 | r_id = sp.repo_id | 634 | r_id = sp.repo_id |
