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

Function encode_in_pack_object_header

pack-write.c:507–528  ·  view source on GitHub ↗

* The per-object header is a pretty dense thing, which is * - first byte: low four bits are "size", then three bits of "type", * and the high bit is "size continues". * - each byte afterwards: low seven bits are size continuation, * with the high bit being "size continues" */

Source from the content-addressed store, hash-verified

505 * with the high bit being "size continues"
506 */
507int encode_in_pack_object_header(unsigned char *hdr, int hdr_len,
508 enum object_type type, uintmax_t size)
509{
510 int n = 1;
511 unsigned char c;
512
513 if (type < OBJ_COMMIT || type > OBJ_REF_DELTA)
514 die("bad type %d", type);
515
516 c = (type << 4) | (size & 15);
517 size >>= 4;
518 while (size) {
519 if (n == hdr_len)
520 die("object size is too enormous to format");
521 *hdr++ = c | 0x80;
522 c = size & 0x7f;
523 size >>= 7;
524 n++;
525 }
526 *hdr = c;
527 return n;
528}
529
530struct hashfile *create_tmp_packfile(struct repository *repo,
531 char **pack_tmp_name)

Callers 8

stream_blob_to_packFunction · 0.85
write_ref_deltaFunction · 0.85
write_pack_objectFunction · 0.85
store_objectFunction · 0.85
stream_blobFunction · 0.85
write_no_reuse_objectFunction · 0.85
write_reuse_objectFunction · 0.85
write_reused_pack_oneFunction · 0.85

Calls 1

dieFunction · 0.70

Tested by 2

write_ref_deltaFunction · 0.68
write_pack_objectFunction · 0.68