| 2309 | } |
| 2310 | |
| 2311 | static void add_git_context_json(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *root_path) { |
| 2312 | cbm_git_context_t ctx = {0}; |
| 2313 | (void)cbm_git_context_resolve(root_path, &ctx); |
| 2314 | |
| 2315 | yyjson_mut_val *git = yyjson_mut_obj(doc); |
| 2316 | yyjson_mut_obj_add_bool(doc, git, "is_git", ctx.is_git); |
| 2317 | yyjson_mut_obj_add_bool(doc, git, "is_worktree", ctx.is_worktree); |
| 2318 | yyjson_mut_obj_add_bool(doc, git, "is_detached", ctx.is_detached); |
| 2319 | yyjson_mut_obj_add_bool(doc, git, "root_exists", ctx.root_exists); |
| 2320 | add_git_context_string(doc, git, "worktree_root", ctx.worktree_root); |
| 2321 | add_git_context_string(doc, git, "git_dir", ctx.git_dir); |
| 2322 | add_git_context_string(doc, git, "git_common_dir", ctx.git_common_dir); |
| 2323 | add_git_context_string(doc, git, "canonical_root", ctx.canonical_root); |
| 2324 | add_git_context_string(doc, git, "branch", ctx.branch); |
| 2325 | add_git_context_string(doc, git, "branch_slug", ctx.branch_slug); |
| 2326 | add_git_context_string(doc, git, "head_sha", ctx.head_sha); |
| 2327 | add_git_context_string(doc, git, "base_sha", ctx.base_sha); |
| 2328 | yyjson_mut_obj_add_val(doc, obj, "git", git); |
| 2329 | |
| 2330 | cbm_git_context_free(&ctx); |
| 2331 | } |
| 2332 | |
| 2333 | /* Build a helpful error listing available projects. Caller must free() result. */ |
| 2334 | static char *build_project_list_error(const char *reason) { |
no test coverage detected