Create a minimal git repo at dir (init + empty commit so HEAD exists). */
| 47 | |
| 48 | /* Create a minimal git repo at dir (init + empty commit so HEAD exists). */ |
| 49 | static int make_git_repo(const char *dir) { |
| 50 | if (th_mkdir_p(dir) != 0) return -1; |
| 51 | if (git_run(dir, "init -q") != 0) return -1; |
| 52 | if (git_run(dir, "config user.email test@example.com") != 0) return -1; |
| 53 | if (git_run(dir, "config user.name Test") != 0) return -1; |
| 54 | /* Create a file so HEAD points to a real commit. */ |
| 55 | char path[1024]; |
| 56 | snprintf(path, sizeof(path), "%s/.keep", dir); |
| 57 | th_write_file(path, ""); |
| 58 | if (git_run(dir, "add .keep") != 0) return -1; |
| 59 | if (git_run(dir, "commit -q -m init") != 0) return -1; |
| 60 | return 0; |
| 61 | } |
| 62 | #endif /* _WIN32 */ |
| 63 | |
| 64 | /* ── canonical_root: normal repo indexed from its root ──────────── */ |
no test coverage detected