Skip to content

Commit 8d6ccce

Browse files
pcloudsgitster
authored andcommitted
pack-objects: a bit of document about struct object_entry
The role of this comment block becomes more important after we shuffle fields around to shrink this struct. It will be much harder to see what field is related to what. Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4c2db93 commit 8d6ccce

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

pack-objects.h

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,51 @@
11
#ifndef PACK_OBJECTS_H
22
#define PACK_OBJECTS_H
33

4+
/*
5+
* basic object info
6+
* -----------------
7+
* idx.oid is filled up before delta searching starts. idx.crc32 is
8+
* only valid after the object is written out and will be used for
9+
* generating the index. idx.offset will be both gradually set and
10+
* used in writing phase (base objects get offset first, then deltas
11+
* refer to them)
12+
*
13+
* "size" is the uncompressed object size. Compressed size of the raw
14+
* data for an object in a pack is not stored anywhere but is computed
15+
* and made available when reverse .idx is made.
16+
*
17+
* "hash" contains a path name hash which is used for sorting the
18+
* delta list and also during delta searching. Once prepare_pack()
19+
* returns it's no longer needed.
20+
*
21+
* source pack info
22+
* ----------------
23+
* The (in_pack, in_pack_offset) tuple contains the location of the
24+
* object in the source pack. in_pack_header_size allows quickly
25+
* skipping the header and going straight to the zlib stream.
26+
*
27+
* "type" and "in_pack_type" both describe object type. in_pack_type
28+
* may contain a delta type, while type is always the canonical type.
29+
*
30+
* deltas
31+
* ------
32+
* Delta links (delta, delta_child and delta_sibling) are created to
33+
* reflect that delta graph from the source pack then updated or added
34+
* during delta searching phase when we find better deltas.
35+
*
36+
* delta_child and delta_sibling are last needed in
37+
* compute_write_order(). "delta" and "delta_size" must remain valid
38+
* at object writing phase in case the delta is not cached.
39+
*
40+
* If a delta is cached in memory and is compressed, delta_data points
41+
* to the data and z_delta_size contains the compressed size. If it's
42+
* uncompressed [1], z_delta_size must be zero. delta_size is always
43+
* the uncompressed size and must be valid even if the delta is not
44+
* cached.
45+
*
46+
* [1] during try_delta phase we don't bother with compressing because
47+
* the delta could be quickly replaced with a better one.
48+
*/
449
struct object_entry {
550
struct pack_idx_entry idx;
651
unsigned long size; /* uncompressed size */

0 commit comments

Comments
 (0)