| 111 | } |
| 112 | |
| 113 | static char *join_root_relative(const char *root, const char *rel) { |
| 114 | if (!root || !root[0]) { |
| 115 | return git_strdup(rel); |
| 116 | } |
| 117 | int n = snprintf(NULL, 0, "%s/%s", root, rel); |
| 118 | if (n < 0) { |
| 119 | return NULL; |
| 120 | } |
| 121 | char *out = (char *)malloc((size_t)n + 1); |
| 122 | if (!out) { |
| 123 | return NULL; |
| 124 | } |
| 125 | snprintf(out, (size_t)n + 1, "%s/%s", root, rel); |
| 126 | return out; |
| 127 | } |
| 128 | |
| 129 | /* Derive the canonical repo root. |
| 130 | * |
no test coverage detected