| 101 | } |
| 102 | |
| 103 | static char *join_root_relative(const char *root, const char *rel) { |
| 104 | if (!root || !root[0]) { |
| 105 | return git_strdup(rel); |
| 106 | } |
| 107 | int n = snprintf(NULL, 0, "%s/%s", root, rel); |
| 108 | if (n < 0) { |
| 109 | return NULL; |
| 110 | } |
| 111 | char *out = (char *)malloc((size_t)n + 1); |
| 112 | if (!out) { |
| 113 | return NULL; |
| 114 | } |
| 115 | snprintf(out, (size_t)n + 1, "%s/%s", root, rel); |
| 116 | return out; |
| 117 | } |
| 118 | |
| 119 | /* Derive the canonical repo root. |
| 120 | * |
no test coverage detected