From 584863fb5e3e17ab364de40f80b10ac030b47788 Mon Sep 17 00:00:00 2001 From: Kaushik Lingarkar Date: Wed, 16 Oct 2024 14:17:24 -0700 Subject: [PATCH] Fix incremental syncs for prjs with submodules When performing an incremental sync (re-running repo init with an updated manifest revision) with --fetch-submodules or sync-s=true, there is an attempt to get a list of all projects (including submodules) before projects are actually fetched. However, we can only list submodules of a project if we have already fetched its revision. Instead of throwing an error when we don't have the revision, assume there are no submodules for that project. In the sync cmd, we already update the list of projects to include submodules after fetching superprojects. Change-Id: I48bc68c48b5b10117356b18f5375d17f9a89ec05 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/439761 Commit-Queue: Kaushik Lingarkar Tested-by: Kaushik Lingarkar Reviewed-by: Josip Sokcevic Reviewed-by: Nasser Grainawi --- project.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/project.py b/project.py index 1d8ab556..50daa82f 100644 --- a/project.py +++ b/project.py @@ -2296,7 +2296,9 @@ class Project: try: rev = self.GetRevisionId() - except GitError: + except (GitError, ManifestInvalidRevisionError): + # The git repo may be outdated (i.e. not fetched yet) and querying + # its submodules using the revision may not work; so return here. return [] return get_submodules(self.gitdir, rev)