MCPcopy Index your code
hub / github.com/git/git / parse_object_with_flags

Function parse_object_with_flags

object.c:322–396  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

320}
321
322struct object *parse_object_with_flags(struct repository *r,
323 const struct object_id *oid,
324 enum parse_object_flags flags)
325{
326 int skip_hash = !!(flags & PARSE_OBJECT_SKIP_HASH_CHECK);
327 int discard_tree = !!(flags & PARSE_OBJECT_DISCARD_TREE);
328 size_t size;
329 enum object_type type;
330 int eaten;
331 const struct object_id *repl = lookup_replace_object(r, oid);
332 void *buffer;
333 struct object *obj;
334
335 obj = lookup_object(r, oid);
336 if (obj && obj->parsed)
337 return obj;
338
339 if (skip_hash) {
340 struct commit *commit = lookup_commit_in_graph(r, repl);
341 if (commit)
342 return &commit->object;
343 }
344
345 if ((!obj || obj->type == OBJ_NONE || obj->type == OBJ_BLOB) &&
346 odb_read_object_info(r->objects, oid, NULL) == OBJ_BLOB) {
347 if (!skip_hash) {
348 struct odb_read_stream *stream = odb_read_stream_open(r->objects, oid, NULL);
349
350 if (!stream) {
351 error(_("unable to open object stream for %s"), oid_to_hex(oid));
352 return NULL;
353 }
354
355 if (stream_object_signature(r, stream, repl) < 0) {
356 error(_("hash mismatch %s"), oid_to_hex(oid));
357 odb_read_stream_close(stream);
358 return NULL;
359 }
360
361 odb_read_stream_close(stream);
362 }
363 parse_blob_buffer(lookup_blob(r, oid));
364 return lookup_object(r, oid);
365 }
366
367 /*
368 * If the caller does not care about the tree buffer and does not
369 * care about checking the hash, we can simply verify that we
370 * have the on-disk object with the correct type.
371 */
372 if (skip_hash && discard_tree &&
373 (!obj || obj->type == OBJ_NONE || obj->type == OBJ_TREE) &&
374 odb_read_object_info(r->objects, oid, NULL) == OBJ_TREE) {
375 return &lookup_tree(r, oid)->object;
376 }
377
378 buffer = odb_read_object(r->objects, oid, &type, &size);
379 if (buffer) {

Callers 7

match_points_atFunction · 0.85
do_got_oidFunction · 0.85
receive_needsFunction · 0.85
parse_wantFunction · 0.85
add_promisor_objectFunction · 0.85
get_referenceFunction · 0.85
parse_objectFunction · 0.85

Calls 15

lookup_replace_objectFunction · 0.85
lookup_objectFunction · 0.85
lookup_commit_in_graphFunction · 0.85
odb_read_object_infoFunction · 0.85
odb_read_stream_openFunction · 0.85
errorFunction · 0.85
oid_to_hexFunction · 0.85
stream_object_signatureFunction · 0.85
odb_read_stream_closeFunction · 0.85
parse_blob_bufferFunction · 0.85
lookup_blobFunction · 0.85
lookup_treeFunction · 0.85

Tested by

no test coverage detected