MCPcopy Create free account
hub / github.com/git/git / odb_source_loose_write_object

Function odb_source_loose_write_object

odb/source-loose.c:585–625  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

583}
584
585static int odb_source_loose_write_object(struct odb_source *source,
586 const void *buf, unsigned long len,
587 enum object_type type, struct object_id *oid,
588 struct object_id *compat_oid_in,
589 enum odb_write_object_flags flags)
590{
591 struct odb_source_loose *loose = odb_source_loose_downcast(source);
592 const struct git_hash_algo *algo = source->odb->repo->hash_algo;
593 const struct git_hash_algo *compat = source->odb->repo->compat_hash_algo;
594 struct object_id compat_oid;
595 char hdr[MAX_HEADER_LEN];
596 int hdrlen = sizeof(hdr);
597
598 /* Generate compat_oid */
599 if (compat) {
600 if (compat_oid_in)
601 oidcpy(&compat_oid, compat_oid_in);
602 else if (type == OBJ_BLOB)
603 hash_object_file(compat, buf, len, type, &compat_oid);
604 else {
605 struct strbuf converted = STRBUF_INIT;
606 convert_object_file(source->odb->repo, &converted, algo, compat,
607 buf, len, type, 0);
608 hash_object_file(compat, converted.buf, converted.len,
609 type, &compat_oid);
610 strbuf_release(&converted);
611 }
612 }
613
614 /* Normally if we have it in the pack then we do not bother writing
615 * it out into .git/objects/??/?{38} file.
616 */
617 write_object_file_prepare(algo, buf, len, type, oid, hdr, &hdrlen);
618 if (odb_freshen_object(source->odb, oid))
619 return 0;
620 if (write_loose_object(loose, oid, hdr, hdrlen, buf, len, 0, flags))
621 return -1;
622 if (compat)
623 return repo_add_loose_object_map(loose, oid, &compat_oid);
624 return 0;
625}
626
627static int odb_source_loose_write_object_stream(struct odb_source *source,
628 struct odb_write_stream *in_stream,

Callers

nothing calls this directly

Calls 9

oidcpyFunction · 0.85
hash_object_fileFunction · 0.85
convert_object_fileFunction · 0.85
strbuf_releaseFunction · 0.85
odb_freshen_objectFunction · 0.85
write_loose_objectFunction · 0.85

Tested by

no test coverage detected