| 251 | } |
| 252 | |
| 253 | int convert_object_file(struct repository *repo, |
| 254 | struct strbuf *outbuf, |
| 255 | const struct git_hash_algo *from, |
| 256 | const struct git_hash_algo *to, |
| 257 | const void *buf, size_t len, |
| 258 | enum object_type type, |
| 259 | int gentle) |
| 260 | { |
| 261 | int ret; |
| 262 | |
| 263 | /* Don't call this function when no conversion is necessary */ |
| 264 | if ((from == to) || (type == OBJ_BLOB)) |
| 265 | BUG("Refusing noop object file conversion"); |
| 266 | |
| 267 | switch (type) { |
| 268 | case OBJ_COMMIT: |
| 269 | ret = convert_commit_object(repo, outbuf, from, to, buf, len); |
| 270 | break; |
| 271 | case OBJ_TREE: |
| 272 | ret = convert_tree_object(repo, outbuf, from, to, buf, len); |
| 273 | break; |
| 274 | case OBJ_TAG: |
| 275 | ret = convert_tag_object(repo, outbuf, from, to, buf, len); |
| 276 | break; |
| 277 | default: |
| 278 | /* Not implemented yet, so fail. */ |
| 279 | ret = -1; |
| 280 | break; |
| 281 | } |
| 282 | if (!ret) |
| 283 | return 0; |
| 284 | if (gentle) { |
| 285 | strbuf_release(outbuf); |
| 286 | return ret; |
| 287 | } |
| 288 | die(_("Failed to convert object from %s to %s"), |
| 289 | from->name, to->name); |
| 290 | } |
no test coverage detected