Skip to content

Commit 181d033

Browse files
dschoGit for Windows Build Agent
authored andcommitted
Continue improving support for 4GB+ packs/clones/objects (#6289)
This PR contains a branch thicket on top of v2.55.0-rc1 (i.e. ready to go upstream) to continue the bulk of the `unsigned long` -> `size_t` transformation. Since all of these changes have no impact on the currently-working functionality for <4GB objects/packs/clones (modulo bugs, that is 😄), I would like to merge this before v2.55.0-rc2, still: The risk of introducing a regression is negligible, the chance for fixing the majority of problems with large clones is high.
2 parents 7129bd1 + b391157 commit 181d033

47 files changed

Lines changed: 190 additions & 250 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

builtin/cat-file.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -202,11 +202,9 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
202202

203203
case 'c':
204204
{
205-
unsigned long size_ul = 0;
206205
int textconv_ret = textconv_object(the_repository, path,
207206
obj_context.mode, &oid, 1,
208-
&buf, &size_ul);
209-
size = size_ul;
207+
&buf, &size);
210208
if (textconv_ret)
211209
break;
212210
}
@@ -448,12 +446,9 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d
448446
oid_to_hex(oid), data->rest);
449447
} else if (opt->transform_mode == 'c') {
450448
enum object_type type;
451-
unsigned long size_ul = 0;
452-
if (textconv_object(the_repository,
453-
data->rest, 0100644, oid,
454-
1, &contents, &size_ul))
455-
size = size_ul;
456-
else
449+
if (!textconv_object(the_repository,
450+
data->rest, 0100644, oid,
451+
1, &contents, &size))
457452
contents = odb_read_object(the_repository->objects,
458453
oid, &type, &size);
459454
if (!contents)

builtin/fast-export.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ static void show_progress(void)
285285
* There's no need to cache this result with anonymize_mem, since
286286
* we already handle blob content caching with marks.
287287
*/
288-
static char *anonymize_blob(unsigned long *size)
288+
static char *anonymize_blob(size_t *size)
289289
{
290290
static int counter;
291291
struct strbuf out = STRBUF_INIT;
@@ -296,7 +296,7 @@ static char *anonymize_blob(unsigned long *size)
296296

297297
static void export_blob(const struct object_id *oid)
298298
{
299-
unsigned long size;
299+
size_t size;
300300
enum object_type type;
301301
char *buf;
302302
struct object *object;
@@ -317,10 +317,8 @@ static void export_blob(const struct object_id *oid)
317317
object = (struct object *)lookup_blob(the_repository, oid);
318318
eaten = 0;
319319
} else {
320-
size_t size_st = 0;
321320
buf = odb_read_object(the_repository->objects, oid, &type,
322-
&size_st);
323-
size = cast_size_t_to_ulong(size_st);
321+
&size);
324322
if (!buf)
325323
die(_("could not read blob %s"), oid_to_hex(oid));
326324
if (check_object_signature(the_repository, oid, buf, size,

builtin/fast-import.c

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -962,7 +962,7 @@ static int store_object(
962962
struct object_entry *e;
963963
unsigned char hdr[96];
964964
struct object_id oid;
965-
unsigned long hdrlen, deltalen;
965+
size_t hdrlen, deltalen;
966966
struct git_hash_ctx c;
967967
git_zstream s;
968968
struct repo_config_values *cfg = repo_config_values(the_repository);
@@ -998,7 +998,6 @@ static int store_object(
998998

999999
if (last && last->data.len && last->data.buf && last->depth < max_depth
10001000
&& dat->len > the_hash_algo->rawsz) {
1001-
10021001
delta_count_attempts_by_type[type]++;
10031002
delta = diff_delta(last->data.buf, last->data.len,
10041003
dat->buf, dat->len,
@@ -1238,10 +1237,9 @@ static void stream_blob(uintmax_t len, struct object_id *oidout, uintmax_t mark)
12381237
*/
12391238
static void *gfi_unpack_entry(
12401239
struct object_entry *oe,
1241-
unsigned long *sizep)
1240+
size_t *sizep)
12421241
{
12431242
enum object_type type;
1244-
size_t size_st = 0;
12451243
void *data;
12461244
struct packed_git *p = all_packs[oe->pack_id];
12471245
if (p == pack_data && p->pack_size < (pack_size + the_hash_algo->rawsz)) {
@@ -1264,9 +1262,7 @@ static void *gfi_unpack_entry(
12641262
*/
12651263
p->pack_size = pack_size + the_hash_algo->rawsz;
12661264
}
1267-
data = unpack_entry(the_repository, p, oe->idx.offset, &type, &size_st);
1268-
if (sizep)
1269-
*sizep = cast_size_t_to_ulong(size_st);
1265+
data = unpack_entry(the_repository, p, oe->idx.offset, &type, sizep);
12701266
return data;
12711267
}
12721268

@@ -1275,7 +1271,7 @@ static void load_tree(struct tree_entry *root)
12751271
struct object_id *oid = &root->versions[1].oid;
12761272
struct object_entry *myoe;
12771273
struct tree_content *t;
1278-
unsigned long size;
1274+
size_t size;
12791275
char *buf;
12801276
const char *c;
12811277

@@ -1293,10 +1289,8 @@ static void load_tree(struct tree_entry *root)
12931289
die(_("can't load tree %s"), oid_to_hex(oid));
12941290
} else {
12951291
enum object_type type;
1296-
size_t size_st = 0;
12971292
buf = odb_read_object(the_repository->objects, oid, &type,
1298-
&size_st);
1299-
size = cast_size_t_to_ulong(size_st);
1293+
&size);
13001294
if (!buf || type != OBJ_TREE)
13011295
die(_("can't load tree %s"), oid_to_hex(oid));
13021296
}
@@ -2614,7 +2608,7 @@ static void file_change_deleteall(struct branch *b)
26142608
b->num_notes = 0;
26152609
}
26162610

2617-
static void parse_from_commit(struct branch *b, char *buf, unsigned long size)
2611+
static void parse_from_commit(struct branch *b, char *buf, size_t size)
26182612
{
26192613
if (!buf || size < the_hash_algo->hexsz + 6)
26202614
die(_("not a valid commit: %s"), oid_to_hex(&b->oid));
@@ -2631,13 +2625,11 @@ static void parse_from_existing(struct branch *b)
26312625
oidclr(&b->branch_tree.versions[0].oid, the_repository->hash_algo);
26322626
oidclr(&b->branch_tree.versions[1].oid, the_repository->hash_algo);
26332627
} else {
2634-
unsigned long size;
2635-
size_t size_st = 0;
2628+
size_t size;
26362629
char *buf;
26372630

26382631
buf = odb_read_object_peeled(the_repository->objects, &b->oid,
2639-
OBJ_COMMIT, &size_st, &b->oid);
2640-
size = cast_size_t_to_ulong(size_st);
2632+
OBJ_COMMIT, &size, &b->oid);
26412633
parse_from_commit(b, buf, size);
26422634
free(buf);
26432635
}
@@ -2666,7 +2658,7 @@ static int parse_objectish(struct branch *b, const char *objectish)
26662658
if (!oideq(&b->oid, &oe->idx.oid)) {
26672659
oidcpy(&b->oid, &oe->idx.oid);
26682660
if (oe->pack_id != MAX_PACK_ID) {
2669-
unsigned long size;
2661+
size_t size;
26702662
char *buf = gfi_unpack_entry(oe, &size);
26712663
parse_from_commit(b, buf, size);
26722664
free(buf);
@@ -3332,15 +3324,13 @@ static void cat_blob_write(const char *buf, unsigned long size)
33323324
static void cat_blob(struct object_entry *oe, struct object_id *oid)
33333325
{
33343326
struct strbuf line = STRBUF_INIT;
3335-
unsigned long size;
3327+
size_t size;
33363328
enum object_type type = 0;
33373329
char *buf;
33383330

33393331
if (!oe || oe->pack_id == MAX_PACK_ID) {
3340-
size_t size_st = 0;
33413332
buf = odb_read_object(the_repository->objects, oid, &type,
3342-
&size_st);
3343-
size = cast_size_t_to_ulong(size_st);
3333+
&size);
33443334
} else {
33453335
type = oe->type;
33463336
buf = gfi_unpack_entry(oe, &size);
@@ -3419,7 +3409,7 @@ static void parse_cat_blob(const char *p)
34193409
static struct object_entry *dereference(struct object_entry *oe,
34203410
struct object_id *oid)
34213411
{
3422-
unsigned long size;
3412+
size_t size;
34233413
char *buf = NULL;
34243414
const unsigned hexsz = the_hash_algo->hexsz;
34253415

@@ -3448,10 +3438,8 @@ static struct object_entry *dereference(struct object_entry *oe,
34483438
buf = gfi_unpack_entry(oe, &size);
34493439
} else {
34503440
enum object_type unused;
3451-
size_t size_st = 0;
34523441
buf = odb_read_object(the_repository->objects, oid,
3453-
&unused, &size_st);
3454-
size = cast_size_t_to_ulong(size_st);
3442+
&unused, &size);
34553443
}
34563444
if (!buf)
34573445
die(_("can't load object %s"), oid_to_hex(oid));

builtin/log.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ static int show_blob_object(const struct object_id *oid, struct rev_info *rev, c
584584
struct object_id oidc;
585585
struct object_context obj_context = {0};
586586
char *buf;
587-
unsigned long size;
587+
size_t size;
588588

589589
fflush(rev->diffopt.file);
590590
if (!rev->diffopt.flags.textconv_set_via_cmdline ||

0 commit comments

Comments
 (0)