| 2718 | } |
| 2719 | |
| 2720 | static void add_git_context_json(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *root_path) { |
| 2721 | cbm_git_context_t ctx = {0}; |
| 2722 | (void)cbm_git_context_resolve(root_path, &ctx); |
| 2723 | |
| 2724 | yyjson_mut_val *git = yyjson_mut_obj(doc); |
| 2725 | yyjson_mut_obj_add_bool(doc, git, "is_git", ctx.is_git); |
| 2726 | yyjson_mut_obj_add_bool(doc, git, "is_worktree", ctx.is_worktree); |
| 2727 | yyjson_mut_obj_add_bool(doc, git, "is_detached", ctx.is_detached); |
| 2728 | yyjson_mut_obj_add_bool(doc, git, "root_exists", ctx.root_exists); |
| 2729 | add_git_context_string(doc, git, "worktree_root", ctx.worktree_root); |
| 2730 | add_git_context_string(doc, git, "git_dir", ctx.git_dir); |
| 2731 | add_git_context_string(doc, git, "git_common_dir", ctx.git_common_dir); |
| 2732 | add_git_context_string(doc, git, "canonical_root", ctx.canonical_root); |
| 2733 | add_git_context_string(doc, git, "branch", ctx.branch); |
| 2734 | add_git_context_string(doc, git, "branch_slug", ctx.branch_slug); |
| 2735 | add_git_context_string(doc, git, "head_sha", ctx.head_sha); |
| 2736 | add_git_context_string(doc, git, "base_sha", ctx.base_sha); |
| 2737 | yyjson_mut_obj_add_val(doc, obj, "git", git); |
| 2738 | |
| 2739 | cbm_git_context_free(&ctx); |
| 2740 | } |
| 2741 | |
| 2742 | /* Build a helpful error listing available projects. Caller must free() result. */ |
| 2743 | static char *build_project_list_error(const char *reason) { |
no test coverage detected