| 126 | } |
| 127 | |
| 128 | static char *join_root_relative(const char *root, const char *rel) { |
| 129 | if (!root || !root[0]) { |
| 130 | return git_strdup(rel); |
| 131 | } |
| 132 | int n = snprintf(NULL, 0, "%s/%s", root, rel); |
| 133 | if (n < 0) { |
| 134 | return NULL; |
| 135 | } |
| 136 | char *out = (char *)malloc((size_t)n + 1); |
| 137 | if (!out) { |
| 138 | return NULL; |
| 139 | } |
| 140 | snprintf(out, (size_t)n + 1, "%s/%s", root, rel); |
| 141 | return out; |
| 142 | } |
| 143 | |
| 144 | /* Derive the canonical repo root. |
| 145 | * |
no test coverage detected