ci: Allow running iwyu ci in worktree
What changed, and why it matters
This is a harmless CI (continuous integration) maintenance change. It lets an optional code-style check called IWYU run in environments like git worktrees or archives where a full git history isn't present. It does not touch Bitcoin's network code, wallet, consensus, or any user-facing behavior.
No security action needed. This is a CI infrastructure convenience patch.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch modifies ci/test/03_test_script.sh to create a temporary dummy git repository inside the CI working directory when RUN_IWYU=true. It backs up any existing .git directory, initializes a fresh repo, stages ./src, sets a dummy committer identity, and makes a dummy commit. This is purely to satisfy the git-diff-based IWYU (Include What You Use) check when the CI job is run from a git-archive or git-worktree that lacks a usable git history. No source code, build system, cryptography, or network logic is changed.
Changed components
ci/test/03_test_script.shInspect captured patch +13 / −0
diff --git a/ci/test/03_test_script.sh b/ci/test/03_test_script.sh
index d04ff992..cfec6c26 100755
--- a/ci/test/03_test_script.sh
+++ b/ci/test/03_test_script.sh
@@ -49,6 +49,19 @@ echo "=== BEGIN env ==="
env
echo "=== END env ==="
+# The CI framework should be flexible where it is run from. For example, from
+# a git-archive, a git-worktree, or a normal git repo.
+# The iwyu task requires a working git repo, which may not always be
+# available, so initialize one with force.
+if [[ "${RUN_IWYU}" == true ]]; then
+ mv .git .git_ci_backup || true
+ git init
+ git add ./src # the git diff command used later for iwyu only cares about ./src
+ git config user.email "ci@ci"
+ git config user.name "CI"
+ git commit -m "dummy CI ./src init for IWYU"
+fi
+
if [ "$RUN_FUZZ_TESTS" = "true" ]; then
export DIR_FUZZ_IN=${DIR_QA_ASSETS}/fuzz_corpora/
if [ ! -d "$DIR_FUZZ_IN" ]; then
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.