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

Function write_no_reuse_object

builtin/pack-objects.c:514–630  ·  view source on GitHub ↗

Return 0 if we will bust the pack-size limit */

Source from the content-addressed store, hash-verified

512
513/* Return 0 if we will bust the pack-size limit */
514static unsigned long write_no_reuse_object(struct hashfile *f, struct object_entry *entry,
515 unsigned long limit, int usable_delta)
516{
517 unsigned long size, datalen;
518 unsigned char header[MAX_PACK_OBJECT_HEADER],
519 dheader[MAX_PACK_OBJECT_HEADER];
520 unsigned hdrlen;
521 enum object_type type;
522 void *buf;
523 struct odb_read_stream *st = NULL;
524 const unsigned hashsz = the_hash_algo->rawsz;
525
526 if (!usable_delta) {
527 if (oe_type(entry) == OBJ_BLOB &&
528 oe_size_greater_than(&to_pack, entry,
529 repo_settings_get_big_file_threshold(the_repository)) &&
530 (st = odb_read_stream_open(the_repository->objects, &entry->idx.oid,
531 NULL)) != NULL) {
532 buf = NULL;
533 type = st->type;
534 size = st->size;
535 } else {
536 size_t size_st = 0;
537 buf = odb_read_object(the_repository->objects,
538 &entry->idx.oid, &type,
539 &size_st);
540 size = cast_size_t_to_ulong(size_st);
541 if (!buf)
542 die(_("unable to read %s"),
543 oid_to_hex(&entry->idx.oid));
544 }
545 /*
546 * make sure no cached delta data remains from a
547 * previous attempt before a pack split occurred.
548 */
549 FREE_AND_NULL(entry->delta_data);
550 entry->z_delta_size = 0;
551 } else if (entry->delta_data) {
552 size = DELTA_SIZE(entry);
553 buf = entry->delta_data;
554 entry->delta_data = NULL;
555 type = (allow_ofs_delta && DELTA(entry)->idx.offset) ?
556 OBJ_OFS_DELTA : OBJ_REF_DELTA;
557 } else {
558 buf = get_delta(entry);
559 size = DELTA_SIZE(entry);
560 type = (allow_ofs_delta && DELTA(entry)->idx.offset) ?
561 OBJ_OFS_DELTA : OBJ_REF_DELTA;
562 }
563
564 if (st) /* large blob case, just assume we don't compress well */
565 datalen = size;
566 else if (entry->z_delta_size)
567 datalen = entry->z_delta_size;
568 else
569 datalen = do_compress(&buf, size);
570
571 /*

Callers 2

write_reuse_objectFunction · 0.85
write_objectFunction · 0.85

Calls 14

oe_typeFunction · 0.85
oe_size_greater_thanFunction · 0.85
odb_read_stream_openFunction · 0.85
odb_read_objectFunction · 0.85
cast_size_t_to_ulongFunction · 0.85
oid_to_hexFunction · 0.85
odb_read_stream_closeFunction · 0.85
hashwriteFunction · 0.85
write_large_blob_dataFunction · 0.85
get_deltaFunction · 0.70

Tested by

no test coverage detected