if (odb_has_object(the_repository->objects, &oid, 0)) {
/* We already have the postimage */
enum object_type type;
- unsigned long size;
+ size_t size;
char *result;
result = odb_read_object(the_repository->objects, &oid,
strbuf_addf(buf, "Subproject commit %s\n", oid_to_hex(oid));
} else {
enum object_type type;
- unsigned long sz;
+ size_t sz;
char *result;
result = odb_read_object(the_repository->objects, oid,
static int resolve_to(struct image *image, const struct object_id *result_id)
{
- unsigned long size;
+ size_t size;
enum object_type type;
char *data;
const struct object_id *oid,
unsigned int mode,
enum object_type *type,
- unsigned long *sizep)
+ size_t *sizep)
{
void *buffer;
const struct commit *commit = args->convert ? args->commit : NULL;
write_archive_entry_fn_t write_entry = c->write_entry;
int err;
const char *path_without_prefix;
- unsigned long size;
+ size_t size;
void *buffer;
enum object_type type;
const char *path, unsigned flags)
{
struct object_id oid;
- unsigned long sz;
+ size_t sz;
enum object_type type;
void *buf;
unsigned short mode;
struct commit *commit = p->item;
unsigned commit_flags = commit->object.flags;
enum object_type type;
- unsigned long size;
+ size_t size;
char *buf = odb_read_object(the_repository->objects,
&commit->object.oid, &type,
&size);
textconv_object(opt->repo, o->path, o->mode,
&o->blob_oid, 1, &file->ptr, &file_size))
;
- else
+ else {
+ size_t file_size_st = 0;
file->ptr = odb_read_object(the_repository->objects,
&o->blob_oid, &type,
- &file_size);
+ &file_size_st);
+ file_size = cast_size_t_to_ulong(file_size_st);
+ }
file->size = file_size;
if (!file->ptr)
textconv_object(sb->repo, sb->path, o->mode, &o->blob_oid, 1, (char **) &sb->final_buf,
&sb->final_buf_size))
;
- else
+ else {
+ size_t final_buf_size_st = 0;
sb->final_buf = odb_read_object(the_repository->objects,
&o->blob_oid, &type,
- &sb->final_buf_size);
+ &final_buf_size_st);
+ sb->final_buf_size =
+ cast_size_t_to_ulong(final_buf_size_st);
+ }
if (!sb->final_buf)
die(_("cannot read blob %s for path %s"),
static int filter_object(const char *path, unsigned mode,
const struct object_id *oid,
- char **buf, unsigned long *size)
+ char **buf, size_t *size)
{
enum object_type type;
struct object_id oid;
enum object_type type;
char *buf;
- unsigned long size;
+ size_t size;
struct object_context obj_context = {0};
struct object_info oi = OBJECT_INFO_INIT;
unsigned flags = OBJECT_INFO_LOOKUP_REPLACE;
if (odb_read_object_info_extended(the_repository->objects, &oid, &oi, flags) < 0)
die("git cat-file: could not get object info");
- if (use_mailmap && (type == OBJ_COMMIT || type == OBJ_TAG)) {
- size_t s = size;
- buf = replace_idents_using_mailmap(buf, &s);
- size = cast_size_t_to_ulong(s);
- }
+ if (use_mailmap && (type == OBJ_COMMIT || type == OBJ_TAG))
+ buf = replace_idents_using_mailmap(buf, &size);
printf("%"PRIuMAX"\n", (uintmax_t)size);
ret = 0;
break;
case 'c':
- if (textconv_object(the_repository, path, obj_context.mode,
- &oid, 1, &buf, &size))
+ {
+ unsigned long size_ul = 0;
+ int textconv_ret = textconv_object(the_repository, path,
+ obj_context.mode, &oid, 1,
+ &buf, &size_ul);
+ size = size_ul;
+ if (textconv_ret)
break;
+ }
/* else fallthrough */
case 'p':
if (!buf)
die("Cannot read object %s", obj_name);
- if (use_mailmap) {
- size_t s = size;
- buf = replace_idents_using_mailmap(buf, &s);
- size = cast_size_t_to_ulong(s);
- }
+ if (use_mailmap)
+ buf = replace_idents_using_mailmap(buf, &size);
/* otherwise just spit out the data */
break;
buf = odb_read_object_peeled(the_repository->objects, &oid,
exp_type_id, &size, NULL);
- if (use_mailmap) {
- size_t s = size;
- buf = replace_idents_using_mailmap(buf, &s);
- size = cast_size_t_to_ulong(s);
- }
+ if (use_mailmap)
+ buf = replace_idents_using_mailmap(buf, &size);
break;
}
default:
struct expand_data {
struct object_id oid;
enum object_type type;
- unsigned long size;
+ size_t size;
unsigned short mode;
off_t disk_size;
const char *rest;
fflush(stdout);
if (opt->transform_mode) {
char *contents;
- unsigned long size;
+ size_t size;
if (!data->rest)
die("missing path for '%s'", oid_to_hex(oid));
oid_to_hex(oid), data->rest);
} else if (opt->transform_mode == 'c') {
enum object_type type;
- if (!textconv_object(the_repository,
- data->rest, 0100644, oid,
- 1, &contents, &size))
+ unsigned long size_ul = 0;
+ if (textconv_object(the_repository,
+ data->rest, 0100644, oid,
+ 1, &contents, &size_ul))
+ size = size_ul;
+ else
contents = odb_read_object(the_repository->objects,
oid, &type, &size);
if (!contents)
}
else {
enum object_type type;
- unsigned long size;
+ size_t size;
void *contents;
contents = odb_read_object(the_repository->objects, oid,
if (!contents)
die("object %s disappeared", oid_to_hex(oid));
- if (use_mailmap) {
- size_t s = size;
- contents = replace_idents_using_mailmap(contents, &s);
- size = cast_size_t_to_ulong(s);
- }
+ if (use_mailmap)
+ contents = replace_idents_using_mailmap(contents, &size);
if (type != data->type)
die("object %s changed type!?", oid_to_hex(oid));
}
if (use_mailmap && (data->type == OBJ_COMMIT || data->type == OBJ_TAG)) {
- size_t s = data->size;
char *buf = NULL;
buf = odb_read_object(the_repository->objects, &data->oid,
&data->type, &data->size);
if (!buf)
die(_("unable to read %s"), oid_to_hex(&data->oid));
- buf = replace_idents_using_mailmap(buf, &s);
- data->size = cast_size_t_to_ulong(s);
+ buf = replace_idents_using_mailmap(buf, &data->size);
free(buf);
}
data = strbuf_detach(&link, NULL);
} else {
enum object_type type;
- unsigned long size;
+ size_t size;
data = odb_read_object(repo->objects, oid, &type, &size);
if (!data)
die(_("could not read object %s for symlink %s"),
object = (struct object *)lookup_blob(the_repository, oid);
eaten = 0;
} else {
- buf = odb_read_object(the_repository->objects, oid, &type, &size);
+ size_t size_st = 0;
+ buf = odb_read_object(the_repository->objects, oid, &type,
+ &size_st);
+ size = cast_size_t_to_ulong(size_st);
if (!buf)
die(_("could not read blob %s"), oid_to_hex(oid));
if (check_object_signature(the_repository, oid, buf, size,
static void handle_tag(const char *name, struct tag *tag)
{
- unsigned long size;
+ size_t size;
enum object_type type;
char *buf;
const char *tagger, *tagger_end, *message;
die(_("can't load tree %s"), oid_to_hex(oid));
} else {
enum object_type type;
- buf = odb_read_object(the_repository->objects, oid, &type, &size);
+ size_t size_st = 0;
+ buf = odb_read_object(the_repository->objects, oid, &type,
+ &size_st);
+ size = cast_size_t_to_ulong(size_st);
if (!buf || type != OBJ_TREE)
die(_("can't load tree %s"), oid_to_hex(oid));
}
die(_("mark :%" PRIuMAX " not a commit"), commit_mark);
oidcpy(&commit_oid, &commit_oe->idx.oid);
} else if (!repo_get_oid(the_repository, p, &commit_oid)) {
- unsigned long size;
+ size_t size;
char *buf = odb_read_object_peeled(the_repository->objects,
&commit_oid, OBJ_COMMIT, &size,
&commit_oid);
oidclr(&b->branch_tree.versions[1].oid, the_repository->hash_algo);
} else {
unsigned long size;
+ size_t size_st = 0;
char *buf;
buf = odb_read_object_peeled(the_repository->objects, &b->oid,
- OBJ_COMMIT, &size, &b->oid);
+ OBJ_COMMIT, &size_st, &b->oid);
+ size = cast_size_t_to_ulong(size_st);
parse_from_commit(b, buf, size);
free(buf);
}
die(_("mark :%" PRIuMAX " not a commit"), idnum);
oidcpy(&n->oid, &oe->idx.oid);
} else if (!repo_get_oid(the_repository, from, &n->oid)) {
- unsigned long size;
+ size_t size;
char *buf = odb_read_object_peeled(the_repository->objects,
&n->oid, OBJ_COMMIT,
&size, &n->oid);
char *buf;
if (!oe || oe->pack_id == MAX_PACK_ID) {
- buf = odb_read_object(the_repository->objects, oid, &type, &size);
+ size_t size_st = 0;
+ buf = odb_read_object(the_repository->objects, oid, &type,
+ &size_st);
+ size = cast_size_t_to_ulong(size_st);
} else {
type = oe->type;
buf = gfi_unpack_entry(oe, &size);
buf = gfi_unpack_entry(oe, &size);
} else {
enum object_type unused;
+ size_t size_st = 0;
buf = odb_read_object(the_repository->objects, oid,
- &unused, &size);
+ &unused, &size_st);
+ size = cast_size_t_to_ulong(size_st);
}
if (!buf)
die(_("can't load object %s"), oid_to_hex(oid));
struct for_each_loose_cb *data = cb_data;
struct object *obj;
enum object_type type = OBJ_NONE;
- unsigned long size;
+ size_t size;
void *contents = NULL;
int eaten;
struct object_info oi = OBJECT_INFO_INIT;
enum object_type object_type;
struct tree_desc tree;
void *data;
- unsigned long size;
+ size_t size;
struct strbuf base = STRBUF_INIT;
obj_read_lock();
enum object_type type;
struct tree_desc tree;
void *data;
- unsigned long size;
+ size_t size;
data = odb_read_object(the_repository->objects, &ce->oid,
&type, &size);
enum object_type type;
struct tree_desc sub;
void *data;
- unsigned long size;
+ size_t size;
data = odb_read_object(the_repository->objects,
&entry.oid, &type, &size);
enum object_type type;
struct tree_desc sub_tree;
void *data;
- unsigned long size;
+ size_t size;
data = odb_read_object(repo->objects, &entry.oid,
&type, &size);
{
struct tree_desc tree;
void *data;
- unsigned long size;
+ size_t size;
struct strbuf base = STRBUF_INIT;
int len;
if (obj->type == OBJ_COMMIT || obj->type == OBJ_TREE) {
struct tree_desc tree;
void *data;
- unsigned long size;
+ size_t size;
struct strbuf base;
int hit, len;
return 0;
if (!(obj->flags & FLAG_CHECKED)) {
- unsigned long size;
+ size_t size;
int type = odb_read_object_info(the_repository->objects,
&obj->oid, &size);
if (type <= 0)
if (collision_test_needed) {
void *has_data;
enum object_type has_type;
- unsigned long has_size;
+ size_t has_size;
read_lock();
has_type = odb_read_object_info(the_repository->objects, oid, &has_size);
if (has_type < 0)
struct ref_delta_entry *d = sorted_by_pos[i];
enum object_type type;
void *data;
- unsigned long size;
+ size_t size;
if (objects[d->obj_no].real_type != OBJ_REF_DELTA)
continue;
static int show_tag_object(const struct object_id *oid, struct rev_info *rev)
{
- unsigned long size;
+ size_t size;
enum object_type type;
char *buf = odb_read_object(the_repository->objects, oid, &type, &size);
unsigned long offset = 0;
size_t len;
if (type == OBJ_BLOB) {
- unsigned long size;
+ size_t size;
if (odb_read_object_info(repo->objects, oid, &size) < 0)
die(_("could not get object info about '%s'"),
oid_to_hex(oid));
size_t len;
if (type == OBJ_BLOB) {
- unsigned long size;
+ size_t size;
if (odb_read_object_info(the_repository->objects, oid, &size) < 0)
die(_("could not get object info about '%s'"),
oid_to_hex(oid));
return early;
if (type == OBJ_BLOB) {
- unsigned long size;
+ size_t size;
if (odb_read_object_info(the_repository->objects, oid, &size) == OBJ_BAD)
xsnprintf(size_text, sizeof(size_text), "BAD");
else
return "removed in remote";
}
-static void *result(struct merge_list *entry, unsigned long *size)
+static void *result(struct merge_list *entry, size_t *size)
{
enum object_type type;
struct blob *base, *our, *their;
base, our, their, size);
}
-static void *origin(struct merge_list *entry, unsigned long *size)
+static void *origin(struct merge_list *entry, size_t *size)
{
enum object_type type;
while (entry) {
static void show_diff(struct merge_list *entry)
{
- unsigned long size;
+ size_t size;
mmfile_t src, dst;
xpparam_t xpp;
xdemitconf_t xecfg;
{
int ret;
enum object_type type;
- unsigned long size;
+ size_t size;
void *buffer;
const struct object_id *repl;
static void copy_obj_to_fd(int fd, const struct object_id *oid)
{
- unsigned long size;
+ size_t size;
enum object_type type;
char *buf = odb_read_object(the_repository->objects, oid, &type, &size);
if (buf) {
char *value;
struct object_id object;
enum object_type type;
- unsigned long len;
+ size_t len;
BUG_ON_OPT_NEG(unset);
if (note && !edit) {
/* Append buf to previous note contents */
- unsigned long size;
+ size_t size;
enum object_type type;
struct strbuf buf = STRBUF_INIT;
char *prev_buf = odb_read_object(the_repository->objects, note, &type, &size);
unsigned long size, base_size, delta_size;
void *buf, *base_buf, *delta_buf;
enum object_type type;
+ size_t size_st = 0, base_size_st = 0;
buf = odb_read_object(the_repository->objects, &entry->idx.oid,
- &type, &size);
+ &type, &size_st);
+ size = cast_size_t_to_ulong(size_st);
if (!buf)
die(_("unable to read %s"), oid_to_hex(&entry->idx.oid));
base_buf = odb_read_object(the_repository->objects,
&DELTA(entry)->idx.oid, &type,
- &base_size);
+ &base_size_st);
+ base_size = cast_size_t_to_ulong(base_size_st);
if (!base_buf)
die("unable to read %s",
oid_to_hex(&DELTA(entry)->idx.oid));
type = st->type;
size = st->size;
} else {
+ size_t size_st = 0;
buf = odb_read_object(the_repository->objects,
&entry->idx.oid, &type,
- &size);
+ &size_st);
+ size = cast_size_t_to_ulong(size_st);
if (!buf)
die(_("unable to read %s"),
oid_to_hex(&entry->idx.oid));
struct pbase_tree_cache *ent, *nent;
void *data;
unsigned long size;
+ size_t size_st = 0;
enum object_type type;
int neigh;
int my_ix = pbase_tree_cache_ix(oid);
/* Did not find one. Either we got a bogus request or
* we need to read and perhaps cache.
*/
- data = odb_read_object(the_repository->objects, oid, &type, &size);
+ data = odb_read_object(the_repository->objects, oid, &type, &size_st);
+ size = cast_size_t_to_ulong(size_st);
if (!data)
return NULL;
if (type != OBJ_TREE) {
struct pbase_tree *it;
void *data;
unsigned long size;
+ size_t size_st = 0;
struct object_id tree_oid;
if (window <= num_preferred_base++)
return;
data = odb_read_object_peeled(the_repository->objects, oid,
- OBJ_TREE, &size, &tree_oid);
+ OBJ_TREE, &size_st, &tree_oid);
+ size = cast_size_t_to_ulong(size_st);
if (!data)
return;
static void check_object(struct object_entry *entry, uint32_t object_index)
{
- unsigned long canonical_size;
+ size_t canonical_size;
enum object_type type;
struct object_info oi = {.typep = &type, .sizep = &canonical_size};
unsigned *idx = &to_pack.objects[entry->delta_idx - 1].delta_child_idx;
struct object_info oi = OBJECT_INFO_INIT;
enum object_type type;
- unsigned long size;
+ size_t size;
while (*idx) {
struct object_entry *oe = &to_pack.objects[*idx - 1];
size_t size;
if (e->type_ != OBJ_OFS_DELTA && e->type_ != OBJ_REF_DELTA) {
- unsigned long sz;
+ size_t sz;
packing_data_lock(&to_pack);
if (odb_read_object_info(the_repository->objects,
&e->idx.oid, &sz) < 0)
/* Load data if not already done */
if (!trg->data) {
+ size_t sz_st = 0;
packing_data_lock(&to_pack);
trg->data = odb_read_object(the_repository->objects,
&trg_entry->idx.oid, &type,
- &sz);
+ &sz_st);
+ sz = cast_size_t_to_ulong(sz_st);
packing_data_unlock(&to_pack);
if (!trg->data)
die(_("object %s cannot be read"),
*mem_usage += sz;
}
if (!src->data) {
+ size_t sz_st = 0;
packing_data_lock(&to_pack);
src->data = odb_read_object(the_repository->objects,
&src_entry->idx.oid, &type,
- &sz);
+ &sz_st);
+ sz = cast_size_t_to_ulong(sz_st);
packing_data_unlock(&to_pack);
if (!src->data) {
if (src_entry->preferred_base) {
for (size_t i = 0; i < oids->nr; i++) {
struct object_info oi = OBJECT_INFO_INIT;
unsigned long inflated;
+ size_t inflated_st = 0;
struct commit *commit;
struct object *obj;
void *content;
off_t disk;
int eaten;
- oi.sizep = &inflated;
+ oi.sizep = &inflated_st;
oi.disk_sizep = &disk;
oi.contentp = &content;
OBJECT_INFO_SKIP_FETCH_OBJECT |
OBJECT_INFO_QUICK) < 0)
continue;
+ inflated = cast_size_t_to_ulong(inflated_st);
obj = parse_object_buffer(the_repository, &oids->oid[i], type,
inflated, content, &eaten);
static void write_tag_body(int fd, const struct object_id *oid)
{
- unsigned long size;
+ size_t size;
enum object_type type;
char *buf, *sp, *orig;
struct strbuf payload = STRBUF_INIT;
enum object_type type;
struct commit *c;
char *buf;
- unsigned long size;
+ size_t size;
int subject_len = 0;
const char *subject_start;
static char path[50];
void *buf;
enum object_type type;
- unsigned long size;
+ size_t size;
int fd;
buf = odb_read_object(the_repository->objects, oid, &type, &size);
die("object type mismatch");
if (!(obj->flags & FLAG_OPEN)) {
- unsigned long size;
+ size_t size;
int type = odb_read_object_info(the_repository->objects, &obj->oid, &size);
if (type != obj->type || type <= 0)
die("object of unexpected type");
{
void *delta_data, *base;
unsigned long base_size;
+ size_t base_size_st = 0;
struct object_id base_oid;
if (type == OBJ_REF_DELTA) {
return;
base = odb_read_object(the_repository->objects, &base_oid,
- &type, &base_size);
+ &type, &base_size_st);
+ base_size = cast_size_t_to_ulong(base_size_st);
if (!base) {
error("failed to read delta-pack base object %s",
oid_to_hex(&base_oid));
static int is_tag_in_date_range(struct object *tag, struct rev_info *revs)
{
- unsigned long size;
+ size_t size;
enum object_type type;
char *buf = NULL, *line, *lineend;
timestamp_t date;
*size = fill_textconv(r, textconv, df, &blob);
free_filespec(df);
} else {
- blob = odb_read_object(r->objects, oid, &type, size);
+ size_t size_st = 0;
+ blob = odb_read_object(r->objects, oid, &type, &size_st);
+ *size = cast_size_t_to_ulong(size_st);
if (!blob)
die(_("unable to read %s"), oid_to_hex(oid));
if (type != OBJ_BLOB)
const void *ret = get_cached_commit_buffer(r, commit, sizep);
if (!ret) {
enum object_type type;
- unsigned long size;
+ size_t size;
ret = odb_read_object(r->objects, &commit->object.oid, &type, &size);
if (!ret)
die("cannot read commit object %s",
die("expected commit for %s, got %s",
oid_to_hex(&commit->object.oid), type_name(type));
if (sizep)
- *sizep = size;
+ *sizep = cast_size_t_to_ulong(size);
}
return ret;
}
static void load_tree_from_commit_contents(struct repository *r, struct commit *commit)
{
enum object_type type;
- unsigned long size;
+ size_t size;
char *buf;
const char *p;
struct object_id tree_oid;
{
enum object_type type;
void *buffer;
- unsigned long size;
+ size_t size;
struct object_info oi = {
.typep = &type,
.sizep = &size,
struct merge_remote_desc *desc;
struct commit_extra_header *mergetag;
char *buf;
- unsigned long size;
+ size_t size;
enum object_type type;
struct strbuf payload = STRBUF_INIT;
struct strbuf signature = STRBUF_INIT;
{
enum object_type type;
char *buf;
- unsigned long size;
+ size_t size;
int ret;
buf = odb_read_object(repo->objects, oid, &type, &size);
}
}
else {
+ size_t size_st = 0;
struct object_info info = {
- .sizep = &s->size
+ .sizep = &size_st
};
if (!(size_only || check_binary))
die("unable to read %s", oid_to_hex(&s->oid));
object_read:
+ s->size = cast_size_t_to_ulong(size_st);
if (size_only || check_binary) {
if (size_only)
return 0;
if (odb_read_object_info_extended(r->objects, &s->oid, &info,
OBJECT_INFO_LOOKUP_REPLACE))
die("unable to read %s", oid_to_hex(&s->oid));
+ s->size = cast_size_t_to_ulong(size_st);
}
s->should_free = 1;
}
size_t *size_out, char **data_out)
{
enum object_type type;
- unsigned long sz;
+ size_t sz;
char *data;
*size_out = 0;
void *read_blob_entry(const struct cache_entry *ce, size_t *size)
{
enum object_type type;
- unsigned long ul;
void *blob_data = odb_read_object(the_repository->objects, &ce->oid,
- &type, &ul);
+ &type, size);
- *size = ul;
if (blob_data) {
if (type == OBJ_BLOB)
return blob_data;
for (i = 0; i < origins.nr; i++) {
struct object_id *oid = origins.items[i].util;
enum object_type type;
- unsigned long size;
+ size_t size;
char *buf = odb_read_object(the_repository->objects, oid,
&type, &size);
char *origbuf = buf;
- unsigned long len = size;
+ size_t len = size;
struct signature_check sigc = { NULL };
struct strbuf payload = STRBUF_INIT, sig = STRBUF_INIT;
oidset_iter_init(blobs_found, &iter);
while ((oid = oidset_iter_next(&iter))) {
enum object_type type;
- unsigned long size;
+ size_t size;
char *buf;
if (oidset_contains(blobs_done, oid))
static int grep_source_load_oid(struct grep_source *gs)
{
enum object_type type;
+ size_t size_st = 0;
gs->buf = odb_read_object(gs->repo->objects, gs->identifier,
- &type, &gs->size);
+ &type, &size_st);
+ gs->size = cast_size_t_to_ulong(size_st);
if (!gs->buf)
return error(_("'%s': unable to read %s"),
gs->name,
enum object_type type;
char hdr[50];
void *unpacked;
- unsigned long len;
+ size_t len;
int hdrlen;
ssize_t size;
git_zstream stream;
void *filter_data_)
{
struct filter_blobs_limit_data *filter_data = filter_data_;
- unsigned long object_length;
+ size_t object_length;
enum object_type t;
switch (filter_situation) {
{
struct object_id oid;
char *buf;
- unsigned long size;
+ size_t size;
enum object_type type;
if (!name)
{
void *buffer;
enum object_type type;
- unsigned long size;
+ size_t size;
buffer = odb_read_object(r->objects, hash, &type, &size);
if (!buffer)
char *subpath;
int toplen;
char *buf;
- unsigned long sz;
+ size_t sz;
struct tree_desc desc;
unsigned char *rewrite_here;
const struct object_id *rewrite_with;
static int fill_mmfile_blob(mmfile_t *f, struct blob *obj)
{
void *buf;
- unsigned long size;
+ size_t size;
enum object_type type;
buf = odb_read_object(the_repository->objects, &obj->object.oid,
mmfile_t *base,
mmfile_t *our,
mmfile_t *their,
- unsigned long *size)
+ size_t *size)
{
enum ll_merge_result merge_status;
mmbuffer_t res;
void *merge_blobs(struct index_state *istate, const char *path,
struct blob *base, struct blob *our,
- struct blob *their, unsigned long *size)
+ struct blob *their, size_t *size)
{
void *res = NULL;
mmfile_t f1, f2, common;
void *merge_blobs(struct index_state *, const char *,
struct blob *, struct blob *,
- struct blob *, unsigned long *);
+ struct blob *, size_t *);
#endif /* MERGE_BLOBS_H */
{
void *buf;
enum object_type type;
- unsigned long size;
+ size_t size;
buf = odb_read_object(opt->repo->objects, oid, &type, &size);
if (!buf) {
path_msg(opt, ERROR_OBJECT_READ_FAILED, 0,
const struct object_id *value_oid;
enum object_type type;
char *value;
- unsigned long size;
+ size_t size;
value_oid = get_note(&c->tree, key_oid);
if (!value_oid)
const struct object_id *note)
{
enum object_type type;
- unsigned long size;
+ size_t size;
void *buf = odb_read_object(the_repository->objects, note, &type, &size);
if (!buf)
const struct object_id *new_oid)
{
char *cur_msg = NULL, *new_msg = NULL, *buf;
- unsigned long cur_len, new_len, buf_len;
+ unsigned long buf_len;
+ size_t cur_len, new_len;
enum object_type cur_type, new_type;
int ret;
const struct object_id *oid)
{
char *data;
- unsigned long len;
+ size_t len;
enum object_type t;
if (is_null_oid(oid))
static const char utf8[] = "utf-8";
const struct object_id *oid;
char *msg, *msg_p;
- unsigned long linelen, msglen;
+ unsigned long linelen;
+ size_t msglen;
enum object_type type;
if (!t)
}
if (oi->sizep)
- *oi->sizep = cast_size_t_to_ulong(size);
+ *oi->sizep = size;
/*
* The length must be followed by a zero byte
struct odb_source_files *files = odb_source_files_downcast(source);
const struct git_hash_algo *compat = source->odb->repo->compat_hash_algo;
void *buf;
- unsigned long len;
+ size_t len;
struct object_info oi = OBJECT_INFO_INIT;
struct object_id compat_oid;
enum object_type type;
unsigned long mapsize;
git_zstream stream;
char hdr[MAX_HEADER_LEN];
- unsigned long *size = oi->sizep;
+ size_t *size = oi->sizep;
fd = git_open(path);
if (fd >= 0)
{
int skip_hash = !!(flags & PARSE_OBJECT_SKIP_HASH_CHECK);
int discard_tree = !!(flags & PARSE_OBJECT_DISCARD_TREE);
- unsigned long size;
+ size_t size;
enum object_type type;
int eaten;
const struct object_id *repl = lookup_replace_object(r, oid);
enum object_type type;
struct object_id oid, delta_base_oid;
struct object_info new_oi, *oi;
- unsigned long size;
+ size_t size;
void *content;
int ret;
/* returns enum object_type or negative */
int odb_read_object_info(struct object_database *odb,
const struct object_id *oid,
- unsigned long *sizep)
+ size_t *sizep)
{
enum object_type type;
struct object_info oi = OBJECT_INFO_INIT;
}
int odb_pretend_object(struct object_database *odb,
- void *buf, unsigned long len, enum object_type type,
+ void *buf, size_t len, enum object_type type,
struct object_id *oid)
{
hash_object_file(odb->repo->hash_algo, buf, len, type, oid);
void *odb_read_object(struct object_database *odb,
const struct object_id *oid,
enum object_type *type,
- unsigned long *size)
+ size_t *size)
{
struct object_info oi = OBJECT_INFO_INIT;
unsigned flags = OBJECT_INFO_DIE_IF_CORRUPT | OBJECT_INFO_LOOKUP_REPLACE;
void *odb_read_object_peeled(struct object_database *odb,
const struct object_id *oid,
enum object_type required_type,
- unsigned long *size,
+ size_t *size,
struct object_id *actual_oid_return)
{
enum object_type type;
void *buffer;
- unsigned long isize;
+ size_t isize;
struct object_id actual_oid;
oidcpy(&actual_oid, oid);
void *odb_read_object(struct object_database *odb,
const struct object_id *oid,
enum object_type *type,
- unsigned long *size);
+ size_t *size);
void *odb_read_object_peeled(struct object_database *odb,
const struct object_id *oid,
enum object_type required_type,
- unsigned long *size,
+ size_t *size,
struct object_id *oid_ret);
/*
* that reference it.
*/
int odb_pretend_object(struct object_database *odb,
- void *buf, unsigned long len, enum object_type type,
+ void *buf, size_t len, enum object_type type,
struct object_id *oid);
struct object_info {
/* Request */
enum object_type *typep;
- unsigned long *sizep;
+ size_t *sizep;
off_t *disk_sizep;
struct object_id *delta_base_oid;
void **contentp;
*/
int odb_read_object_info(struct object_database *odb,
const struct object_id *oid,
- unsigned long *sizep);
+ size_t *sizep);
enum odb_has_object_flags {
/* Retry packed storage after checking packed and loose storage */
void *map = NULL;
git_zstream stream, *stream_to_end = NULL;
char hdr[MAX_HEADER_LEN];
- unsigned long size_scratch;
+ size_t size_scratch;
enum object_type type_scratch;
struct stat st;
struct object_info oi = OBJECT_INFO_INIT;
struct odb_loose_read_stream *st;
unsigned long mapsize;
- unsigned long size_ul;
void *mapped;
mapped = odb_source_loose_map_object(loose, oid, &mapsize);
goto error;
}
- /*
- * object_info.sizep is unsigned long* (32-bit on Windows), but
- * st->base.size is size_t (64-bit). Use temporary variable.
- * Note: loose objects >4GB would still truncate here, but such
- * large loose objects are uncommon (they'd normally be packed).
- */
- oi.sizep = &size_ul;
+ oi.sizep = &st->base.size;
oi.typep = &st->base.type;
if (parse_loose_header(st->hdr, &oi) < 0 || st->base.type < 0)
goto error;
- st->base.size = size_ul;
st->mapped = mapped;
st->mapsize = mapsize;
.base.read = read_istream_incore,
};
struct odb_incore_read_stream *st;
- unsigned long size_ul;
int ret;
oi.typep = &stream.base.type;
- /*
- * object_info.sizep is unsigned long* (32-bit on Windows), but
- * stream.base.size is size_t (64-bit). We use a temporary variable
- * because the types are incompatible. Note: this path still truncates
- * for >4GB objects, but large objects should use pack streaming
- * (packfile_store_read_object_stream) which handles size_t properly.
- * This incore fallback is only used for small objects or when pack
- * streaming is unavailable.
- */
- oi.sizep = &size_ul;
+ oi.sizep = &stream.base.size;
oi.contentp = (void **)&stream.buf;
ret = odb_read_object_info_extended(odb, oid, &oi,
OBJECT_INFO_DIE_IF_CORRUPT);
if (ret)
return ret;
- stream.base.size = size_ul;
CALLOC_ARRAY(st, 1);
*st = stream;
static unsigned long get_size_by_pos(struct bitmap_index *bitmap_git,
uint32_t pos)
{
- unsigned long size;
+ size_t size;
struct object_info oi = OBJECT_INFO_INIT;
oi.sizep = &size;
die(_("unable to get size of %s"), oid_to_hex(&obj->oid));
}
- return size;
+ return cast_size_t_to_ulong(size);
}
static void filter_bitmap_blob_limit(struct bitmap_index *bitmap_git,
* a "real" type later if the caller is interested.
*/
if (oi->contentp) {
- size_t size_st = 0;
*oi->contentp = cache_or_unpack_entry(p->repo, p, obj_offset,
- &size_st, &type);
+ oi->sizep, &type);
if (!*oi->contentp)
type = OBJ_BAD;
- else if (oi->sizep)
- *oi->sizep = cast_size_t_to_ulong(size_st);
} else if (oi->sizep || oi->typep || oi->delta_base_oid) {
type = unpack_object_header(p, &w_curs, &curpos, &size);
}
goto out;
}
}
- *oi->sizep = (unsigned long)size;
+ *oi->sizep = size;
}
if (oi->disk_sizep || (oi->mtimep && p->is_cruft)) {
struct object_id base_oid;
if (!(offset_to_pack_pos(p, obj_offset, &pos))) {
struct object_info oi = OBJECT_INFO_INIT;
- unsigned long bsz_ul = 0;
nth_packed_object_id(&base_oid, p,
pack_pos_to_index(p, pos));
mark_bad_packed_object(p, &base_oid);
oi.typep = &type;
- oi.sizep = &bsz_ul;
+ oi.sizep = &base_size;
oi.contentp = &base;
if (odb_read_object_info_extended(r->objects, &base_oid,
&oi, 0) < 0)
base = NULL;
- else
- base_size = bsz_ul;
external_base = base;
}
struct oid_array filtered = OID_ARRAY_INIT;
for (size_t i = 0; i < list->oids.nr; i++) {
- unsigned long size;
+ size_t size;
if (odb_read_object_info(ctx->repo->objects,
&list->oids.oid[i],
for_each_string_list_item (item, oid_str_list) {
const char *oid_str = item->string;
struct object_id oid;
- unsigned long object_size;
+ size_t object_size;
if (get_oid_hex_algop(oid_str, &oid, r->hash_algo) < 0) {
packet_writer_error(
if (odb_read_object_info(r->objects, &oid, &object_size) < 0) {
strbuf_addstr(&send_buffer, " ");
} else {
- strbuf_addf(&send_buffer, " %lu", object_size);
+ strbuf_addf(&send_buffer, " %"PRIuMAX,
+ (uintmax_t)object_size);
}
}
{
int match = -1;
void *buffer;
- unsigned long size;
+ size_t size;
enum object_type type;
struct strbuf sb = STRBUF_INIT;
const char *path, unsigned long *size)
{
int pos, len;
- unsigned long sz;
+ size_t sz;
enum object_type type;
void *data;
return NULL;
}
if (size)
- *size = sz;
+ *size = cast_size_t_to_ulong(sz);
return data;
}
static struct expand_data {
struct object_id oid;
enum object_type type;
- unsigned long size;
+ size_t size;
off_t disk_size;
struct object_id delta_base_oid;
void *content;
if (!tree->buffer) {
enum object_type type;
- unsigned long size;
+ size_t size;
void *data = odb_read_object(the_repository->objects, oid,
&type, &size);
if (!data) {
while (pos < istate->cache_nr) {
enum object_type type;
- unsigned long size;
+ size_t size;
ce = istate->cache[pos++];
if (ce_namelen(ce) != len || memcmp(ce->name, path, len))
enum lookup_type lookup_type)
{
struct strbuf rev = STRBUF_INIT;
- unsigned long config_size;
+ size_t config_size;
char *config = NULL;
struct object_id oid;
enum object_type type;
struct object_id *base)
{
unsigned char header[MAX_PACK_OBJECT_HEADER];
- unsigned long size, base_size, delta_size, compressed_size, hdrlen;
+ unsigned long delta_size, compressed_size, hdrlen;
+ size_t size, base_size;
enum object_type type;
void *base_buf, *delta_buf;
void *buf = odb_read_object(the_repository->objects,
{
struct repository r;
struct object_id oid;
- unsigned long size;
+ size_t size;
struct object_info oi = {.sizep = &size};
const char *p;
const char *expected_content)
{
enum object_type actual_type;
- unsigned long actual_size;
+ size_t actual_size;
void *actual_content;
struct object_info oi = {
.typep = &actual_type,
{
enum object_type type;
char *buf;
- unsigned long size;
+ size_t size;
int ret;
type = odb_read_object_info(r->objects, oid, NULL);
{
enum object_type type;
void *data;
- unsigned long size;
+ size_t size;
int ret;
if (item->object.parsed)
struct tree_desc *desc,
const struct object_id *oid)
{
- unsigned long size = 0;
+ size_t size = 0;
void *buf = NULL;
if (oid) {
{
int retval;
void *tree;
- unsigned long size;
+ size_t size;
struct object_id root;
tree = odb_read_object_peeled(r->objects, tree_oid, OBJ_TREE, &size, &root);
if (!t.buffer) {
void *tree;
struct object_id root;
- unsigned long size;
+ size_t size;
tree = odb_read_object_peeled(r->objects, ¤t_tree_oid,
OBJ_TREE, &size, &root);
if (!tree)
} else if (S_ISLNK(*mode)) {
/* Follow a symlink */
unsigned long link_len;
+ size_t link_len_st = 0;
size_t len;
char *contents, *contents_start;
struct dir_state *parent;
contents = odb_read_object(r->objects,
¤t_tree_oid, &type,
- &link_len);
+ &link_len_st);
+ link_len = cast_size_t_to_ulong(link_len_st);
if (!contents)
goto done;
{
enum object_type type;
void *buffer;
- unsigned long size;
+ size_t size;
if (item->object.parsed)
return 0;
void read_mmblob(mmfile_t *ptr, struct object_database *odb,
const struct object_id *oid)
{
- unsigned long size;
+ size_t size;
enum object_type type;
if (is_null_oid(oid)) {