| 2323 | } |
| 2324 | |
| 2325 | static void add_git_context_json(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *root_path) { |
| 2326 | cbm_git_context_t ctx = {0}; |
| 2327 | (void)cbm_git_context_resolve(root_path, &ctx); |
| 2328 | |
| 2329 | yyjson_mut_val *git = yyjson_mut_obj(doc); |
| 2330 | yyjson_mut_obj_add_bool(doc, git, "is_git", ctx.is_git); |
| 2331 | yyjson_mut_obj_add_bool(doc, git, "is_worktree", ctx.is_worktree); |
| 2332 | yyjson_mut_obj_add_bool(doc, git, "is_detached", ctx.is_detached); |
| 2333 | yyjson_mut_obj_add_bool(doc, git, "root_exists", ctx.root_exists); |
| 2334 | add_git_context_string(doc, git, "worktree_root", ctx.worktree_root); |
| 2335 | add_git_context_string(doc, git, "git_dir", ctx.git_dir); |
| 2336 | add_git_context_string(doc, git, "git_common_dir", ctx.git_common_dir); |
| 2337 | add_git_context_string(doc, git, "canonical_root", ctx.canonical_root); |
| 2338 | add_git_context_string(doc, git, "branch", ctx.branch); |
| 2339 | add_git_context_string(doc, git, "branch_slug", ctx.branch_slug); |
| 2340 | add_git_context_string(doc, git, "head_sha", ctx.head_sha); |
| 2341 | add_git_context_string(doc, git, "base_sha", ctx.base_sha); |
| 2342 | yyjson_mut_obj_add_val(doc, obj, "git", git); |
| 2343 | |
| 2344 | cbm_git_context_free(&ctx); |
| 2345 | } |
| 2346 | |
| 2347 | /* Build a helpful error listing available projects. Caller must free() result. */ |
| 2348 | static char *build_project_list_error(const char *reason) { |
no test coverage detected