From babb887d4b14e50d35592522eb0eebed1c87a4e0 Mon Sep 17 00:00:00 2001 From: MiTHRAL Date: Thu, 27 Aug 2026 11:53:54 -0400 Subject: [PATCH] ci: fix init-submodules empty-worktree check (ls -A counts .git) A submodule with only a .git pointer looks non-empty to ls -A, so the self-heal skipped every un-checked-out nested submodule. Check for real worktree content instead (find excluding .git). --- tools/ci/init-submodules.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/ci/init-submodules.sh b/tools/ci/init-submodules.sh index 6a87d13..572311d 100755 --- a/tools/ci/init-submodules.sh +++ b/tools/ci/init-submodules.sh @@ -25,7 +25,11 @@ fi git submodule update --init --recursive --jobs 4 >/tmp/ghost_sub_init.log 2>&1 || true while IFS= read -r path; do - if [ ! -d "$path" ] || [ -z "$(ls -A "$path" 2>/dev/null)" ]; then + # A submodule needs self-healing when it has no .git, or its worktree + # has no files other than the .git pointer (ls -A counts .git and would + # wrongly treat an un-checked-out submodule as initialized). + if [ ! -e "$path/.git" ] || + [ -z "$(find "$path" -mindepth 1 -maxdepth 1 ! -name '.git' -print -quit 2>/dev/null)" ]; then echo "init-submodules: self-healing empty submodule $path" if (cd "$path" && git fetch --depth 1 origin >/dev/null 2>&1 && git checkout -q FETCH_HEAD >/dev/null 2>&1); then