| 259 | } |
| 260 | |
| 261 | struct object *parse_object_buffer(struct repository *r, const struct object_id *oid, enum object_type type, unsigned long size, void *buffer, int *eaten_p) |
| 262 | { |
| 263 | struct object *obj; |
| 264 | *eaten_p = 0; |
| 265 | |
| 266 | obj = NULL; |
| 267 | if (type == OBJ_BLOB) { |
| 268 | struct blob *blob = lookup_blob(r, oid); |
| 269 | if (blob) { |
| 270 | parse_blob_buffer(blob); |
| 271 | obj = &blob->object; |
| 272 | } |
| 273 | } else if (type == OBJ_TREE) { |
| 274 | struct tree *tree = lookup_tree(r, oid); |
| 275 | if (tree) { |
| 276 | obj = &tree->object; |
| 277 | if (!tree->buffer) |
| 278 | tree->object.parsed = 0; |
| 279 | if (!tree->object.parsed) { |
| 280 | if (parse_tree_buffer(tree, buffer, size)) |
| 281 | return NULL; |
| 282 | *eaten_p = 1; |
| 283 | } |
| 284 | } |
| 285 | } else if (type == OBJ_COMMIT) { |
| 286 | struct commit *commit = lookup_commit(r, oid); |
| 287 | if (commit) { |
| 288 | if (parse_commit_buffer(r, commit, buffer, size, 1)) |
| 289 | return NULL; |
| 290 | if (save_commit_buffer && |
| 291 | !get_cached_commit_buffer(r, commit, NULL)) { |
| 292 | set_commit_buffer(r, commit, buffer, size); |
| 293 | *eaten_p = 1; |
| 294 | } |
| 295 | obj = &commit->object; |
| 296 | } |
| 297 | } else if (type == OBJ_TAG) { |
| 298 | struct tag *tag = lookup_tag(r, oid); |
| 299 | if (tag) { |
| 300 | if (parse_tag_buffer(r, tag, buffer, size)) |
| 301 | return NULL; |
| 302 | obj = &tag->object; |
| 303 | } |
| 304 | } else { |
| 305 | warning(_("object %s has unknown type id %d"), oid_to_hex(oid), type); |
| 306 | obj = NULL; |
| 307 | } |
| 308 | return obj; |
| 309 | } |
| 310 | |
| 311 | struct object *parse_object_or_die(struct repository *repo, |
| 312 | const struct object_id *oid, |
no test coverage detected