From 0e9e938112b9d6f411b2a3893a184e1be2937cde Mon Sep 17 00:00:00 2001
From: Josef Reichardt <Josef-Reichardt@users.noreply.github.com>
Date: Thu, 25 Jul 2024 16:30:02 +0200
Subject: [PATCH] fix(submodules): make git submodule update always recursive
 (#30361)

Co-authored-by: Rhys Arkins <rhys@arkins.net>
---
 docs/usage/configuration-options.md | 1 +
 lib/util/git/index.ts               | 4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/docs/usage/configuration-options.md b/docs/usage/configuration-options.md
index f4c55ad27a..a31af6758f 100644
--- a/docs/usage/configuration-options.md
+++ b/docs/usage/configuration-options.md
@@ -443,6 +443,7 @@ For `sbt` note that Renovate will update the version string only for packages th
 ## cloneSubmodules
 
 Enabling this option will mean that any detected Git submodules will be cloned at time of repository clone.
+Submodules are always cloned recursively.
 
 Important: private submodules aren't supported by Renovate, unless the underlying `ssh` layer already has the correct permissions.
 
diff --git a/lib/util/git/index.ts b/lib/util/git/index.ts
index b29115cab2..5563905673 100644
--- a/lib/util/git/index.ts
+++ b/lib/util/git/index.ts
@@ -354,7 +354,9 @@ export async function cloneSubmodules(shouldClone: boolean): Promise<void> {
   for (const submodule of submodules) {
     try {
       logger.debug(`Cloning git submodule at ${submodule}`);
-      await gitRetry(() => git.submoduleUpdate(['--init', submodule]));
+      await gitRetry(() =>
+        git.submoduleUpdate(['--init', '--recursive', submodule]),
+      );
     } catch (err) {
       logger.warn(
         { err },
-- 
GitLab