mirror of
https://gerrit.googlesource.com/git-repo
synced 2026-10-21 12:48:28 +00:00
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>
This commit is contained in:
1 parent
e7d4d97ffc
commit
310c99571f
4 files changed
+102
-26
No files matched your search
+2
-13
@@ -1614,20 +1614,9 @@ later is required to fix a server side protocol bug.
|
||||
# Only check dirty or locally modified projects. These can't be
|
||||
# freshly cloned and will accumulate garbage.
|
||||
try:
|
||||
status = project._GetStatusSnapshot(
|
||||
untracked_files="normal", branch=True
|
||||
)
|
||||
if status is not None:
|
||||
is_dirty = status.is_dirty(consider_untracked=True)
|
||||
head_rev = status.branch_oid
|
||||
else:
|
||||
is_dirty = project.IsDirty(consider_untracked=True)
|
||||
head_rev = project.work_git.rev_parse(HEAD)
|
||||
|
||||
is_dirty, head_rev = project.GetDirtyAndHead()
|
||||
if head_rev is None:
|
||||
# Porcelain v2 reports an unborn branch as "(initial)". The
|
||||
# legacy rev-parse path failed here and skipped the bloat
|
||||
# calculation, so preserve that behavior.
|
||||
# An unborn branch has no HEAD to compare, so skip it.
|
||||
return None
|
||||
|
||||
manifest_rev = project.GetRevisionId(project.bare_ref.all)
|
||||
|
||||
Reference in new issue
Block a user