From effa534e710772a612d04e5be4a6fe8f47f539d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bence=20Sz=C3=A9pk=C3=BAti?= Date: Thu, 25 Sep 2025 15:51:07 +0200 Subject: [PATCH 1/5] Use worktrees instead of fetches for submodules MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Bence Szépkúti --- scripts/abi_check.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/scripts/abi_check.py b/scripts/abi_check.py index 243e6fc482..f2a7819048 100755 --- a/scripts/abi_check.py +++ b/scripts/abi_check.py @@ -197,6 +197,13 @@ class AbiChecker: """If the crypto submodule is present, initialize it. if version.crypto_revision exists, update it to that revision, otherwise update it to the default revision""" + submodule_output = subprocess.check_output( + [self.git_command, "submodule", "foreach", "--recursive", + 'git worktree add --detach "{}/$displaypath" HEAD'.format(git_worktree_path)], + cwd=self.repo_path, + stderr=subprocess.STDOUT + ) + self.log.debug(submodule_output.decode("utf-8")) update_output = subprocess.check_output( [self.git_command, "submodule", "update", "--init", '--recursive'], cwd=git_worktree_path, @@ -390,6 +397,12 @@ class AbiChecker: def _cleanup_worktree(self, git_worktree_path): """Remove the specified git worktree.""" shutil.rmtree(git_worktree_path) + submodule_output = subprocess.check_output( + [self.git_command, "submodule", "foreach", "--recursive", "git worktree prune"], + cwd=self.repo_path, + stderr=subprocess.STDOUT + ) + self.log.debug(submodule_output.decode("utf-8")) worktree_output = subprocess.check_output( [self.git_command, "worktree", "prune"], cwd=self.repo_path, From dc88f6e1f3fdcc5b7d8afdda61498cd8e85bced5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bence=20Sz=C3=A9pk=C3=BAti?= Date: Fri, 26 Sep 2025 15:37:42 +0200 Subject: [PATCH 2/5] Use f-string literal MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This makes path-construction a bit more readable Signed-off-by: Bence Szépkúti --- scripts/abi_check.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/abi_check.py b/scripts/abi_check.py index f2a7819048..18eb9d3dc1 100755 --- a/scripts/abi_check.py +++ b/scripts/abi_check.py @@ -199,7 +199,7 @@ class AbiChecker: otherwise update it to the default revision""" submodule_output = subprocess.check_output( [self.git_command, "submodule", "foreach", "--recursive", - 'git worktree add --detach "{}/$displaypath" HEAD'.format(git_worktree_path)], + f'git worktree add --detach "{git_worktree_path}/$displaypath" HEAD'], cwd=self.repo_path, stderr=subprocess.STDOUT ) From 8d95062aeb5a2a89d6ba63bf11e11a175385d8ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bence=20Sz=C3=A9pk=C3=BAti?= Date: Fri, 26 Sep 2025 15:44:11 +0200 Subject: [PATCH 3/5] Eliminate use of git worktree prune MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Bence Szépkúti --- scripts/abi_check.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/abi_check.py b/scripts/abi_check.py index 18eb9d3dc1..c526f15ef6 100755 --- a/scripts/abi_check.py +++ b/scripts/abi_check.py @@ -398,13 +398,14 @@ class AbiChecker: """Remove the specified git worktree.""" shutil.rmtree(git_worktree_path) submodule_output = subprocess.check_output( - [self.git_command, "submodule", "foreach", "--recursive", "git worktree prune"], + [self.git_command, "submodule", "foreach", "--recursive", + f'git worktree remove "{git_worktree_path}/$displaypath"'], cwd=self.repo_path, stderr=subprocess.STDOUT ) self.log.debug(submodule_output.decode("utf-8")) worktree_output = subprocess.check_output( - [self.git_command, "worktree", "prune"], + [self.git_command, "worktree", "remove", git_worktree_path], cwd=self.repo_path, stderr=subprocess.STDOUT ) From 0f2a4f3d1fcbcf0f298d4ae6c78c8f9fb423a17e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bence=20Sz=C3=A9pk=C3=BAti?= Date: Fri, 26 Sep 2025 20:10:04 +0200 Subject: [PATCH 4/5] Prevent unnecessary submodule fetches MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Bence Szépkúti --- scripts/abi_check.py | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/scripts/abi_check.py b/scripts/abi_check.py index c526f15ef6..dfe7f9ef15 100755 --- a/scripts/abi_check.py +++ b/scripts/abi_check.py @@ -204,11 +204,24 @@ class AbiChecker: stderr=subprocess.STDOUT ) self.log.debug(submodule_output.decode("utf-8")) - update_output = subprocess.check_output( - [self.git_command, "submodule", "update", "--init", '--recursive'], - cwd=git_worktree_path, - stderr=subprocess.STDOUT - ) + + try: + # Try to update the submodules using local commits + # (Git will sometimes insist on fetching the remote without --no-fetch if the submodules are shallow clones) + update_output = subprocess.check_output( + [self.git_command, "submodule", "update", "--init", '--recursive', '--no-fetch'], + cwd=git_worktree_path, + stderr=subprocess.STDOUT + ) + except subprocess.CalledProcessError as err: + self.log.debug(err.stdout.decode("utf-8")) + + # Checkout with --no-fetch failed, falling back to fetching from origin + update_output = subprocess.check_output( + [self.git_command, "submodule", "update", "--init", '--recursive'], + cwd=git_worktree_path, + stderr=subprocess.STDOUT + ) self.log.debug(update_output.decode("utf-8")) if not (os.path.exists(os.path.join(git_worktree_path, "crypto")) and version.crypto_revision): From 9defedb833210957506c4171e92a6b292d0caa71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bence=20Sz=C3=A9pk=C3=BAti?= Date: Mon, 29 Sep 2025 14:24:25 +0200 Subject: [PATCH 5/5] Fix comment too long for pylint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Bence Szépkúti --- scripts/abi_check.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/abi_check.py b/scripts/abi_check.py index dfe7f9ef15..4fe7f54fc0 100755 --- a/scripts/abi_check.py +++ b/scripts/abi_check.py @@ -207,7 +207,8 @@ class AbiChecker: try: # Try to update the submodules using local commits - # (Git will sometimes insist on fetching the remote without --no-fetch if the submodules are shallow clones) + # (Git will sometimes insist on fetching the remote without --no-fetch + # if the submodules are shallow clones) update_output = subprocess.check_output( [self.git_command, "submodule", "update", "--init", '--recursive', '--no-fetch'], cwd=git_worktree_path,