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