diff options
| author | Gavin Mak <gavinmak@google.com> | 2026-09-23 10:27:17 -0700 |
|---|---|---|
| committer | gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com <gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2026-09-23 13:27:01 -0700 |
| commit | 175198b0aa22a54406be2b651020bb53c3c6d2b7 (patch) | |
| tree | 8b7fc4a1baaa812bb82070b75954f565e7909045 /subcmds/sync.py | |
| parent | 310c99571f49e2d17f79853e69b7c17ff00f1bfc (diff) | |
| download | git-repo-175198b0aa22a54406be2b651020bb53c3c6d2b7.tar.gz | |
sync: skip the bloat check for projects without a worktree
Skip shallow clone bloat checks during --network-only syncs and
filter out projects whose worktree directory does not exist on disk.
Also return None quietly from _GetStatusSnapshot() when a project
lacks an existing worktree directory.
Bug: 565047698
Change-Id: Ia4c7db36a2bd78bc89e7b72f7a492b901b50efa7
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/634425
Commit-Queue: Gavin Mak <gavinmak@google.com>
Reviewed-by: Brian Gan <brgan@google.com>
Tested-by: Gavin Mak <gavinmak@google.com>
Diffstat (limited to 'subcmds/sync.py')
| -rw-r--r-- | subcmds/sync.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/subcmds/sync.py b/subcmds/sync.py index bae367781..a0cb9378f 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py | |||
| @@ -1608,9 +1608,6 @@ later is required to fix a server side protocol bug. | |||
| 1608 | """ | 1608 | """ |
| 1609 | project = cls.get_parallel_context()["projects"][project_index] | 1609 | project = cls.get_parallel_context()["projects"][project_index] |
| 1610 | 1610 | ||
| 1611 | if not project.Exists or not project.worktree: | ||
| 1612 | return None | ||
| 1613 | |||
| 1614 | # Only check dirty or locally modified projects. These can't be | 1611 | # Only check dirty or locally modified projects. These can't be |
| 1615 | # freshly cloned and will accumulate garbage. | 1612 | # freshly cloned and will accumulate garbage. |
| 1616 | try: | 1613 | try: |
| @@ -1660,16 +1657,27 @@ later is required to fix a server side protocol bug. | |||
| 1660 | run 'git count-objects -v' and warn if the repository is accumulating | 1657 | run 'git count-objects -v' and warn if the repository is accumulating |
| 1661 | excessive pack files or garbage. | 1658 | excessive pack files or garbage. |
| 1662 | """ | 1659 | """ |
| 1660 | # --network-only promises not to touch worktrees, but git status and | ||
| 1661 | # update-index --refresh can both rewrite the index. | ||
| 1662 | if opt.network_only: | ||
| 1663 | return | ||
| 1664 | |||
| 1663 | # We only care about bloated projects if we have a git version that | 1665 | # We only care about bloated projects if we have a git version that |
| 1664 | # supports --no-auto-gc (2.23.0+) since what we use to disable auto-gc | 1666 | # supports --no-auto-gc (2.23.0+) since what we use to disable auto-gc |
| 1665 | # in Project._RemoteFetch. | 1667 | # in Project._RemoteFetch. |
| 1666 | if not git_require((2, 23, 0)): | 1668 | if not git_require((2, 23, 0)): |
| 1667 | return | 1669 | return |
| 1668 | 1670 | ||
| 1671 | # Skip projects with no worktree on disk, e.g. ones only ever synced | ||
| 1672 | # with --network-only. | ||
| 1669 | projects = [ | 1673 | projects = [ |
| 1670 | p | 1674 | p |
| 1671 | for p in projects | 1675 | for p in projects |
| 1672 | if p.clone_depth and not p.stateless_prune_needed | 1676 | if p.clone_depth |
| 1677 | and not p.stateless_prune_needed | ||
| 1678 | and p.worktree | ||
| 1679 | and p.Exists | ||
| 1680 | and platform_utils.isdir(p.worktree) | ||
| 1673 | ] | 1681 | ] |
| 1674 | if not projects: | 1682 | if not projects: |
| 1675 | return | 1683 | return |
