@@ -164,12 +164,11 @@ Format of STDIN stream:
164
164
165
165
struct object_entry
166
166
{
167
+ struct pack_idx_entry idx ;
167
168
struct object_entry * next ;
168
- uint32_t offset ;
169
169
uint32_t type : TYPE_BITS ,
170
170
pack_id : PACK_ID_BITS ,
171
171
depth : DEPTH_BITS ;
172
- unsigned char sha1 [20 ];
173
172
};
174
173
175
174
struct object_entry_pool
@@ -521,7 +520,7 @@ static struct object_entry *new_object(unsigned char *sha1)
521
520
alloc_objects (object_entry_alloc );
522
521
523
522
e = blocks -> next_free ++ ;
524
- hashcpy (e -> sha1 , sha1 );
523
+ hashcpy (e -> idx . sha1 , sha1 );
525
524
return e ;
526
525
}
527
526
@@ -530,7 +529,7 @@ static struct object_entry *find_object(unsigned char *sha1)
530
529
unsigned int h = sha1 [0 ] << 8 | sha1 [1 ];
531
530
struct object_entry * e ;
532
531
for (e = object_table [h ]; e ; e = e -> next )
533
- if (!hashcmp (sha1 , e -> sha1 ))
532
+ if (!hashcmp (sha1 , e -> idx . sha1 ))
534
533
return e ;
535
534
return NULL ;
536
535
}
@@ -542,15 +541,15 @@ static struct object_entry *insert_object(unsigned char *sha1)
542
541
struct object_entry * p = NULL ;
543
542
544
543
while (e ) {
545
- if (!hashcmp (sha1 , e -> sha1 ))
544
+ if (!hashcmp (sha1 , e -> idx . sha1 ))
546
545
return e ;
547
546
p = e ;
548
547
e = e -> next ;
549
548
}
550
549
551
550
e = new_object (sha1 );
552
551
e -> next = NULL ;
553
- e -> offset = 0 ;
552
+ e -> idx . offset = 0 ;
554
553
if (p )
555
554
p -> next = e ;
556
555
else
@@ -857,7 +856,7 @@ static int oecmp (const void *a_, const void *b_)
857
856
{
858
857
struct object_entry * a = * ((struct object_entry * * )a_ );
859
858
struct object_entry * b = * ((struct object_entry * * )b_ );
860
- return hashcmp (a -> sha1 , b -> sha1 );
859
+ return hashcmp (a -> idx . sha1 , b -> idx . sha1 );
861
860
}
862
861
863
862
static char * create_index (void )
@@ -887,7 +886,7 @@ static char *create_index(void)
887
886
for (i = 0 ; i < 256 ; i ++ ) {
888
887
struct object_entry * * next = c ;
889
888
while (next < last ) {
890
- if ((* next )-> sha1 [0 ] != i )
889
+ if ((* next )-> idx . sha1 [0 ] != i )
891
890
break ;
892
891
next ++ ;
893
892
}
@@ -901,10 +900,10 @@ static char *create_index(void)
901
900
sha1write (f , array , 256 * sizeof (int ));
902
901
git_SHA1_Init (& ctx );
903
902
for (c = idx ; c != last ; c ++ ) {
904
- uint32_t offset = htonl ((* c )-> offset );
903
+ uint32_t offset = htonl ((* c )-> idx . offset );
905
904
sha1write (f , & offset , 4 );
906
- sha1write (f , (* c )-> sha1 , sizeof ((* c )-> sha1 ));
907
- git_SHA1_Update (& ctx , (* c )-> sha1 , 20 );
905
+ sha1write (f , (* c )-> idx . sha1 , sizeof ((* c )-> idx . sha1 ));
906
+ git_SHA1_Update (& ctx , (* c )-> idx . sha1 , 20 );
908
907
}
909
908
sha1write (f , pack_data -> sha1 , sizeof (pack_data -> sha1 ));
910
909
sha1close (f , NULL , CSUM_FSYNC );
@@ -1063,13 +1062,13 @@ static int store_object(
1063
1062
e = insert_object (sha1 );
1064
1063
if (mark )
1065
1064
insert_mark (mark , e );
1066
- if (e -> offset ) {
1065
+ if (e -> idx . offset ) {
1067
1066
duplicate_count_by_type [type ]++ ;
1068
1067
return 1 ;
1069
1068
} else if (find_sha1_pack (sha1 , packed_git )) {
1070
1069
e -> type = type ;
1071
1070
e -> pack_id = MAX_PACK_ID ;
1072
- e -> offset = 1 ; /* just not zero! */
1071
+ e -> idx . offset = 1 ; /* just not zero! */
1073
1072
duplicate_count_by_type [type ]++ ;
1074
1073
return 1 ;
1075
1074
}
@@ -1127,12 +1126,12 @@ static int store_object(
1127
1126
1128
1127
e -> type = type ;
1129
1128
e -> pack_id = pack_id ;
1130
- e -> offset = pack_size ;
1129
+ e -> idx . offset = pack_size ;
1131
1130
object_count ++ ;
1132
1131
object_count_by_type [type ]++ ;
1133
1132
1134
1133
if (delta ) {
1135
- unsigned long ofs = e -> offset - last -> offset ;
1134
+ unsigned long ofs = e -> idx . offset - last -> offset ;
1136
1135
unsigned pos = sizeof (hdr ) - 1 ;
1137
1136
1138
1137
delta_count_by_type [type ]++ ;
@@ -1165,7 +1164,7 @@ static int store_object(
1165
1164
} else {
1166
1165
strbuf_swap (& last -> data , dat );
1167
1166
}
1168
- last -> offset = e -> offset ;
1167
+ last -> offset = e -> idx . offset ;
1169
1168
last -> depth = e -> depth ;
1170
1169
}
1171
1170
return 0 ;
@@ -1259,22 +1258,22 @@ static void stream_blob(uintmax_t len, unsigned char *sha1out, uintmax_t mark)
1259
1258
if (mark )
1260
1259
insert_mark (mark , e );
1261
1260
1262
- if (e -> offset ) {
1261
+ if (e -> idx . offset ) {
1263
1262
duplicate_count_by_type [OBJ_BLOB ]++ ;
1264
1263
truncate_pack (offset );
1265
1264
1266
1265
} else if (find_sha1_pack (sha1 , packed_git )) {
1267
1266
e -> type = OBJ_BLOB ;
1268
1267
e -> pack_id = MAX_PACK_ID ;
1269
- e -> offset = 1 ; /* just not zero! */
1268
+ e -> idx . offset = 1 ; /* just not zero! */
1270
1269
duplicate_count_by_type [OBJ_BLOB ]++ ;
1271
1270
truncate_pack (offset );
1272
1271
1273
1272
} else {
1274
1273
e -> depth = 0 ;
1275
1274
e -> type = OBJ_BLOB ;
1276
1275
e -> pack_id = pack_id ;
1277
- e -> offset = offset ;
1276
+ e -> idx . offset = offset ;
1278
1277
object_count ++ ;
1279
1278
object_count_by_type [OBJ_BLOB ]++ ;
1280
1279
}
@@ -1326,7 +1325,7 @@ static void *gfi_unpack_entry(
1326
1325
*/
1327
1326
p -> pack_size = pack_size + 20 ;
1328
1327
}
1329
- return unpack_entry (p , oe -> offset , & type , sizep );
1328
+ return unpack_entry (p , oe -> idx . offset , & type , sizep );
1330
1329
}
1331
1330
1332
1331
static const char * get_mode (const char * str , uint16_t * modep )
@@ -1457,7 +1456,7 @@ static void store_tree(struct tree_entry *root)
1457
1456
if (S_ISDIR (root -> versions [0 ].mode ) && le && le -> pack_id == pack_id ) {
1458
1457
mktree (t , 0 , & old_tree );
1459
1458
lo .data = old_tree ;
1460
- lo .offset = le -> offset ;
1459
+ lo .offset = le -> idx . offset ;
1461
1460
lo .depth = t -> delta_depth ;
1462
1461
}
1463
1462
@@ -1715,7 +1714,7 @@ static void dump_marks_helper(FILE *f,
1715
1714
for (k = 0 ; k < 1024 ; k ++ ) {
1716
1715
if (m -> data .marked [k ])
1717
1716
fprintf (f , ":%" PRIuMAX " %s\n" , base + k ,
1718
- sha1_to_hex (m -> data .marked [k ]-> sha1 ));
1717
+ sha1_to_hex (m -> data .marked [k ]-> idx . sha1 ));
1719
1718
}
1720
1719
}
1721
1720
}
@@ -1798,7 +1797,7 @@ static void read_marks(void)
1798
1797
e = insert_object (sha1 );
1799
1798
e -> type = type ;
1800
1799
e -> pack_id = MAX_PACK_ID ;
1801
- e -> offset = 1 ; /* just not zero! */
1800
+ e -> idx . offset = 1 ; /* just not zero! */
1802
1801
}
1803
1802
insert_mark (mark , e );
1804
1803
}
@@ -2183,7 +2182,7 @@ static void file_change_m(struct branch *b)
2183
2182
if (* p == ':' ) {
2184
2183
char * x ;
2185
2184
oe = find_mark (strtoumax (p + 1 , & x , 10 ));
2186
- hashcpy (sha1 , oe -> sha1 );
2185
+ hashcpy (sha1 , oe -> idx . sha1 );
2187
2186
p = x ;
2188
2187
} else if (!prefixcmp (p , "inline" )) {
2189
2188
inline_data = 1 ;
@@ -2316,7 +2315,7 @@ static void note_change_n(struct branch *b, unsigned char old_fanout)
2316
2315
if (* p == ':' ) {
2317
2316
char * x ;
2318
2317
oe = find_mark (strtoumax (p + 1 , & x , 10 ));
2319
- hashcpy (sha1 , oe -> sha1 );
2318
+ hashcpy (sha1 , oe -> idx . sha1 );
2320
2319
p = x ;
2321
2320
} else if (!prefixcmp (p , "inline" )) {
2322
2321
inline_data = 1 ;
@@ -2339,7 +2338,7 @@ static void note_change_n(struct branch *b, unsigned char old_fanout)
2339
2338
struct object_entry * commit_oe = find_mark (commit_mark );
2340
2339
if (commit_oe -> type != OBJ_COMMIT )
2341
2340
die ("Mark :%" PRIuMAX " not a commit" , commit_mark );
2342
- hashcpy (commit_sha1 , commit_oe -> sha1 );
2341
+ hashcpy (commit_sha1 , commit_oe -> idx . sha1 );
2343
2342
} else if (!get_sha1 (p , commit_sha1 )) {
2344
2343
unsigned long size ;
2345
2344
char * buf = read_object_with_reference (commit_sha1 ,
@@ -2446,7 +2445,7 @@ static int parse_from(struct branch *b)
2446
2445
struct object_entry * oe = find_mark (idnum );
2447
2446
if (oe -> type != OBJ_COMMIT )
2448
2447
die ("Mark :%" PRIuMAX " not a commit" , idnum );
2449
- hashcpy (b -> sha1 , oe -> sha1 );
2448
+ hashcpy (b -> sha1 , oe -> idx . sha1 );
2450
2449
if (oe -> pack_id != MAX_PACK_ID ) {
2451
2450
unsigned long size ;
2452
2451
char * buf = gfi_unpack_entry (oe , & size );
@@ -2481,7 +2480,7 @@ static struct hash_list *parse_merge(unsigned int *count)
2481
2480
struct object_entry * oe = find_mark (idnum );
2482
2481
if (oe -> type != OBJ_COMMIT )
2483
2482
die ("Mark :%" PRIuMAX " not a commit" , idnum );
2484
- hashcpy (n -> sha1 , oe -> sha1 );
2483
+ hashcpy (n -> sha1 , oe -> idx . sha1 );
2485
2484
} else if (!get_sha1 (from , n -> sha1 )) {
2486
2485
unsigned long size ;
2487
2486
char * buf = read_object_with_reference (n -> sha1 ,
@@ -2639,7 +2638,7 @@ static void parse_new_tag(void)
2639
2638
from_mark = strtoumax (from + 1 , NULL , 10 );
2640
2639
oe = find_mark (from_mark );
2641
2640
type = oe -> type ;
2642
- hashcpy (sha1 , oe -> sha1 );
2641
+ hashcpy (sha1 , oe -> idx . sha1 );
2643
2642
} else if (!get_sha1 (from , sha1 )) {
2644
2643
unsigned long size ;
2645
2644
char * buf ;
0 commit comments