84
85
static int filter_object(const char *path, unsigned mode,
86
const struct object_id *oid,
87
- char **buf, unsigned long *size)
87
+ char **buf, size_t *size)
88
{
89
enum object_type type;
90
120
struct object_id oid;
121
enum object_type type;
122
char *buf;
123
- unsigned long size;
123
+ size_t size;
124
struct object_context obj_context = {0};
125
struct object_info oi = OBJECT_INFO_INIT;
126
unsigned flags = OBJECT_INFO_LOOKUP_REPLACE;
163
if (odb_read_object_info_extended(the_repository->objects, &oid, &oi, flags) < 0)
164
die("git cat-file: could not get object info");
165
166
- if (use_mailmap && (type == OBJ_COMMIT || type == OBJ_TAG)) {
167
- size_t s = size;
168
- buf = replace_idents_using_mailmap(buf, &s);
169
- size = cast_size_t_to_ulong(s);
170
- }
166
+ if (use_mailmap && (type == OBJ_COMMIT || type == OBJ_TAG))
167
+ buf = replace_idents_using_mailmap(buf, &size);
168
169
printf("%"PRIuMAX"\n", (uintmax_t)size);
170
ret = 0;
185
break;
186
187
case 'c':
191
- if (textconv_object(the_repository, path, obj_context.mode,
192
- &oid, 1, &buf, &size))
188
+ {
189
+ unsigned long size_ul = 0;
190
+ int textconv_ret = textconv_object(the_repository, path,
191
+ obj_context.mode, &oid, 1,
192
+ &buf, &size_ul);
193
+ size = size_ul;
194
+ if (textconv_ret)
195
break;
196
+ }
197
/* else fallthrough */
198
199
case 'p':
219
if (!buf)
220
die("Cannot read object %s", obj_name);
221
219
- if (use_mailmap) {
220
- size_t s = size;
221
- buf = replace_idents_using_mailmap(buf, &s);
222
- size = cast_size_t_to_ulong(s);
223
- }
222
+ if (use_mailmap)
223
+ buf = replace_idents_using_mailmap(buf, &size);
224
225
/* otherwise just spit out the data */
226
break;
263
buf = odb_read_object_peeled(the_repository->objects, &oid,
264
exp_type_id, &size, NULL);
265
266
- if (use_mailmap) {
267
- size_t s = size;
268
- buf = replace_idents_using_mailmap(buf, &s);
269
- size = cast_size_t_to_ulong(s);
270
- }
266
+ if (use_mailmap)
267
+ buf = replace_idents_using_mailmap(buf, &size);
268
break;
269
}
270
default:
285
struct expand_data {
286
struct object_id oid;
287
enum object_type type;
291
- unsigned long size;
288
+ size_t size;
289
unsigned short mode;
290
off_t disk_size;
291
const char *rest;
401
fflush(stdout);
402
if (opt->transform_mode) {
403
char *contents;
407
- unsigned long size;
404
+ size_t size;
405
406
if (!data->rest)
407
die("missing path for '%s'", oid_to_hex(oid));
413
oid_to_hex(oid), data->rest);
414
} else if (opt->transform_mode == 'c') {
415
enum object_type type;
419
- if (!textconv_object(the_repository,
420
- data->rest, 0100644, oid,
421
- 1, &contents, &size))
416
+ unsigned long size_ul = 0;
417
+ if (textconv_object(the_repository,
418
+ data->rest, 0100644, oid,
419
+ 1, &contents, &size_ul))
420
+ size = size_ul;
421
+ else
422
contents = odb_read_object(the_repository->objects,
423
oid, &type, &size);
424
if (!contents)
434
}
435
else {
436
enum object_type type;
437
- unsigned long size;
437
+ size_t size;
438
void *contents;
439
440
contents = odb_read_object(the_repository->objects, oid,
442
if (!contents)
443
die("object %s disappeared", oid_to_hex(oid));
444
445
- if (use_mailmap) {
446
- size_t s = size;
447
- contents = replace_idents_using_mailmap(contents, &s);
448
- size = cast_size_t_to_ulong(s);
449
- }
445
+ if (use_mailmap)
446
+ contents = replace_idents_using_mailmap(contents, &size);
447
448
if (type != data->type)
449
die("object %s changed type!?", oid_to_hex(oid));
543
}
544
545
if (use_mailmap && (data->type == OBJ_COMMIT || data->type == OBJ_TAG)) {
549
- size_t s = data->size;
546
char *buf = NULL;
547
548
buf = odb_read_object(the_repository->objects, &data->oid,
549
&data->type, &data->size);
550
if (!buf)
551
die(_("unable to read %s"), oid_to_hex(&data->oid));
556
- buf = replace_idents_using_mailmap(buf, &s);
557
- data->size = cast_size_t_to_ulong(s);
552
+ buf = replace_idents_using_mailmap(buf, &data->size);
553
554
free(buf);
555
}