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>
This commit is contained in:
Gavin Mak authored and gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com committed 2026-09-23 13:27:01 -07:00
1 parent 310c99571f
commit 175198b0aa
4 files changed
+72 -6

No files matched your search

+8 -1
View File
@@ -886,9 +886,16 @@ class Project:
ahead_behind: bool = False,
show_stash: bool = False,
) -> Optional[git_status.StatusSnapshot]:
"""Read one porcelain-v2 snapshot, or select the legacy path."""
"""Read one porcelain-v2 snapshot, or select the legacy path.
Returns None on Git older than 2.11, when git status fails, or when
the worktree directory is missing. A missing worktree isn't logged:
status can't run there, and the legacy path raises its own error.
"""
if not git_require((2, 11, 0)):
return None
if not self.worktree or not platform_utils.isdir(self.worktree):
return None
try:
return git_status.GetStatus(
self,