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

Function repo_parse_commit_internal

commit.c:600–660  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

598}
599
600int repo_parse_commit_internal(struct repository *r,
601 struct commit *item,
602 int quiet_on_missing,
603 int use_commit_graph)
604{
605 enum object_type type;
606 void *buffer;
607 size_t size;
608 struct object_info oi = {
609 .typep = &type,
610 .sizep = &size,
611 .contentp = &buffer,
612 };
613 /*
614 * Git does not support partial clones that exclude commits, so set
615 * OBJECT_INFO_SKIP_FETCH_OBJECT to fail fast when an object is missing.
616 */
617 int flags = OBJECT_INFO_LOOKUP_REPLACE | OBJECT_INFO_SKIP_FETCH_OBJECT |
618 OBJECT_INFO_DIE_IF_CORRUPT;
619 int ret;
620
621 if (!item)
622 return -1;
623 if (item->object.parsed)
624 return 0;
625 if (use_commit_graph && parse_commit_in_graph(r, item)) {
626 static int commit_graph_paranoia = -1;
627
628 if (commit_graph_paranoia == -1)
629 commit_graph_paranoia = git_env_bool(GIT_COMMIT_GRAPH_PARANOIA, 0);
630
631 if (commit_graph_paranoia && !odb_has_object(r->objects, &item->object.oid, 0)) {
632 unparse_commit(r, &item->object.oid);
633 return quiet_on_missing ? -1 :
634 error(_("commit %s exists in commit-graph but not in the object database"),
635 oid_to_hex(&item->object.oid));
636 }
637
638 return 0;
639 }
640
641 if (odb_read_object_info_extended(r->objects, &item->object.oid,
642 &oi, flags) < 0)
643 return quiet_on_missing ? -1 :
644 error("Could not read %s",
645 oid_to_hex(&item->object.oid));
646 if (type != OBJ_COMMIT) {
647 free(buffer);
648 return error("Object %s not a commit",
649 oid_to_hex(&item->object.oid));
650 }
651
652 ret = parse_commit_buffer(r, item, buffer, size, 0);
653 if (save_commit_buffer && !ret &&
654 !get_cached_commit_buffer(r, item, NULL)) {
655 set_commit_buffer(r, item, buffer, size);
656 return 0;
657 }

Callers 3

verify_one_commit_graphFunction · 0.85
repo_parse_commit_gentlyFunction · 0.85

Calls 10

parse_commit_in_graphFunction · 0.85
git_env_boolFunction · 0.85
odb_has_objectFunction · 0.85
unparse_commitFunction · 0.85
errorFunction · 0.85
oid_to_hexFunction · 0.85
parse_commit_bufferFunction · 0.85
get_cached_commit_bufferFunction · 0.85
set_commit_bufferFunction · 0.85

Tested by

no test coverage detected