summaryrefslogtreecommitdiffstats
path: root/subcmds
diff options
context:
space:
mode:
authorGavin Mak <gavinmak@google.com>2026-08-25 08:48:50 -0700
committergerrit-scoped@luci-project-accounts.iam.gserviceaccount.com <gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com>2026-09-21 13:39:21 -0700
commitaaadd5da35ce63799f902b3bdecc3091676530c9 (patch)
tree22f74767b77fe79a6770e5b71afc4cd7af8c205f /subcmds
parentc9448f986ef952487006e9c2d22989e98655c591 (diff)
downloadgit-repo-aaadd5da35ce63799f902b3bdecc3091676530c9.tar.gz
sync: reuse status HEAD in the bloat scan
The shallow-project bloat check already needs dirty state. Request branch metadata in that same porcelain-v2 snapshot and use branch.oid instead of launching a separate rev-parse, with the existing calls retained as a fallback. Bug: 543851900 Bug: 553599402 Change-Id: I3e7068c2e14c025a53adf92bfe8483b876cfda9d Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/632145 Tested-by: Gavin Mak <gavinmak@google.com> Reviewed-by: Brian Gan <brgan@google.com> Commit-Queue: Gavin Mak <gavinmak@google.com>
Diffstat (limited to 'subcmds')
-rw-r--r--subcmds/sync.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/subcmds/sync.py b/subcmds/sync.py
index 460ebabd1..d60a256b4 100644
--- a/subcmds/sync.py
+++ b/subcmds/sync.py
@@ -1614,10 +1614,23 @@ 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 is_dirty = project.IsDirty(consider_untracked=True) 1617 status = project._GetStatusSnapshot(
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:
1628 # Porcelain v2 reports an unborn branch as "(initial)". The
1629 # legacy rev-parse path failed here and skipped the bloat
1630 # calculation, so preserve that behavior.
1631 return None
1618 1632
1619 manifest_rev = project.GetRevisionId(project.bare_ref.all) 1633 manifest_rev = project.GetRevisionId(project.bare_ref.all)
1620 head_rev = project.work_git.rev_parse(HEAD)
1621 has_local_commits = manifest_rev != head_rev 1634 has_local_commits = manifest_rev != head_rev
1622 1635
1623 if not (is_dirty or has_local_commits): 1636 if not (is_dirty or has_local_commits):