| 2278 | } |
| 2279 | |
| 2280 | static void add_git_context_json(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *root_path) { |
| 2281 | cbm_git_context_t ctx = {0}; |
| 2282 | (void)cbm_git_context_resolve(root_path, &ctx); |
| 2283 | |
| 2284 | yyjson_mut_val *git = yyjson_mut_obj(doc); |
| 2285 | yyjson_mut_obj_add_bool(doc, git, "is_git", ctx.is_git); |
| 2286 | yyjson_mut_obj_add_bool(doc, git, "is_worktree", ctx.is_worktree); |
| 2287 | yyjson_mut_obj_add_bool(doc, git, "is_detached", ctx.is_detached); |
| 2288 | yyjson_mut_obj_add_bool(doc, git, "root_exists", ctx.root_exists); |
| 2289 | add_git_context_string(doc, git, "worktree_root", ctx.worktree_root); |
| 2290 | add_git_context_string(doc, git, "git_dir", ctx.git_dir); |
| 2291 | add_git_context_string(doc, git, "git_common_dir", ctx.git_common_dir); |
| 2292 | add_git_context_string(doc, git, "canonical_root", ctx.canonical_root); |
| 2293 | add_git_context_string(doc, git, "branch", ctx.branch); |
| 2294 | add_git_context_string(doc, git, "branch_slug", ctx.branch_slug); |
| 2295 | add_git_context_string(doc, git, "head_sha", ctx.head_sha); |
| 2296 | add_git_context_string(doc, git, "base_sha", ctx.base_sha); |
| 2297 | yyjson_mut_obj_add_val(doc, obj, "git", git); |
| 2298 | |
| 2299 | cbm_git_context_free(&ctx); |
| 2300 | } |
| 2301 | |
| 2302 | /* Build a helpful error listing available projects. Caller must free() result. */ |
| 2303 | static char *build_project_list_error(const char *reason) { |
no test coverage detected