From e59e2ae757623e64f625a9cdadf1c2010ef82b34 Mon Sep 17 00:00:00 2001 From: Josip Sokcevic Date: Thu, 12 Sep 2024 04:32:25 +0000 Subject: [PATCH] project: run fetch --refetch onacould not parse commit git may gc reachable objects in partial clone repository due to a bug (report: https://lore.kernel.org/git/20240802073143.56731-1-hanyang.tony@bytedance.com/ ). Until git is properly patched and released, force --refetch iff "could not parse commit" is part of git output. --refetch will will ensure that gc'ed objects are retrieved. Bug: b/360889369 Change-Id: I0fc911c591060f859235dcd8d019881106f0858e Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/437017 Commit-Queue: Josip Sokcevic Reviewed-by: Sam Saccone Tested-by: Josip Sokcevic --- project.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/project.py b/project.py index 25a8cdcd..27ea748f 100644 --- a/project.py +++ b/project.py @@ -2659,6 +2659,17 @@ class Project: # Fallthru to sleep+retry logic at the bottom. pass + # TODO(b/360889369#comment24): git may gc commits incorrectly. + # Until the root cause is fixed, retry fetch with --refetch which + # will bring the repository into a good state. + elif gitcmd.stdout and "could not parse commit" in gitcmd.stdout: + cmd.insert(1, "--refetch") + print( + "could not parse commit error, retrying with refetch", + file=output_redir, + ) + continue + # Try to prune remote branches once in case there are conflicts. # For example, if the remote had refs/heads/upstream, but deleted # that and now has refs/heads/upstream/foo.