diff options
| author | Gavin Mak <gavinmak@google.com> | 2026-09-23 10:25:29 -0700 |
|---|---|---|
| committer | gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com <gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2026-09-23 13:26:55 -0700 |
| commit | 310c99571f49e2d17f79853e69b7c17ff00f1bfc (patch) | |
| tree | 00dff159b20833da38cebf108253b0a1996ce119 /subcmds | |
| parent | e7d4d97ffc7c33b4203cbae9d5da8f61d8bf8355 (diff) | |
| download | git-repo-310c99571f49e2d17f79853e69b7c17ff00f1bfc.tar.gz | |
project: don't rerun git status after a failed snapshot
When a status snapshot fails, fall back directly to _IsDirtyLegacy()
instead of IsDirty() to avoid running git status twice.
Expose Project.GetDirtyAndHead() so sync bloat checks can inspect
worktree state without invoking private Project methods.
Bug: 565047698
Change-Id: I6432ed82da88778eec9d151fd5b70bedb1efc62b
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/634424
Reviewed-by: Brian Gan <brgan@google.com>
Commit-Queue: Gavin Mak <gavinmak@google.com>
Tested-by: Gavin Mak <gavinmak@google.com>
Diffstat (limited to 'subcmds')
| -rw-r--r-- | subcmds/sync.py | 15 |
1 files changed, 2 insertions, 13 deletions
diff --git a/subcmds/sync.py b/subcmds/sync.py index d60a256b4..bae367781 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py | |||
| @@ -1614,20 +1614,9 @@ later is required to fix a server side protocol bug. | |||
| 1614 | # Only check dirty or locally modified projects. These can't be | 1614 | # Only check dirty or locally modified projects. These can't be |
| 1615 | # freshly cloned and will accumulate garbage. | 1615 | # freshly cloned and will accumulate garbage. |
| 1616 | try: | 1616 | try: |
| 1617 | status = project._GetStatusSnapshot( | 1617 | is_dirty, head_rev = project.GetDirtyAndHead() |
| 1618 | untracked_files="normal", branch=True | ||
| 1619 | ) | ||
| 1620 | if status is not None: | ||
| 1621 | is_dirty = status.is_dirty(consider_untracked=True) | ||
| 1622 | head_rev = status.branch_oid | ||
| 1623 | else: | ||
| 1624 | is_dirty = project.IsDirty(consider_untracked=True) | ||
| 1625 | head_rev = project.work_git.rev_parse(HEAD) | ||
| 1626 | |||
| 1627 | if head_rev is None: | 1618 | if head_rev is None: |
| 1628 | # Porcelain v2 reports an unborn branch as "(initial)". The | 1619 | # An unborn branch has no HEAD to compare, so skip it. |
| 1629 | # legacy rev-parse path failed here and skipped the bloat | ||
| 1630 | # calculation, so preserve that behavior. | ||
| 1631 | return None | 1620 | return None |
| 1632 | 1621 | ||
| 1633 | manifest_rev = project.GetRevisionId(project.bare_ref.all) | 1622 | manifest_rev = project.GetRevisionId(project.bare_ref.all) |
