mirror of
https://github.com/git-for-windows/git.git
synced 2026-06-27 00:58:30 -05:00
Merge branch 'topic/size-t-followups' (size_t followups depending on seen topics)
This commit is contained in:
6
blame.c
6
blame.c
@@ -2861,20 +2861,18 @@ void setup_scoreboard(struct blame_scoreboard *sb,
|
||||
sb->final_buf_size = o->file.size;
|
||||
}
|
||||
else {
|
||||
size_t final_buf_size_st = 0;
|
||||
o = get_origin(sb->final, sb->path);
|
||||
if (fill_blob_sha1_and_mode(sb->repo, o))
|
||||
die(_("no such path %s in %s"), sb->path, final_commit_name);
|
||||
|
||||
if (sb->revs->diffopt.flags.allow_textconv &&
|
||||
textconv_object(sb->repo, sb->path, o->mode, &o->blob_oid, 1, (char **) &sb->final_buf,
|
||||
&final_buf_size_st))
|
||||
&sb->final_buf_size))
|
||||
;
|
||||
else
|
||||
sb->final_buf = odb_read_object(the_repository->objects,
|
||||
&o->blob_oid, &type,
|
||||
&final_buf_size_st);
|
||||
sb->final_buf_size = cast_size_t_to_ulong(final_buf_size_st);
|
||||
&sb->final_buf_size);
|
||||
|
||||
if (!sb->final_buf)
|
||||
die(_("cannot read blob %s for path %s"),
|
||||
|
||||
2
blame.h
2
blame.h
@@ -117,7 +117,7 @@ struct blame_scoreboard {
|
||||
* indexed with scoreboard.lineno[blame_entry.lno].
|
||||
*/
|
||||
char *final_buf;
|
||||
unsigned long final_buf_size;
|
||||
size_t final_buf_size;
|
||||
|
||||
/* linked list of blames */
|
||||
struct blame_entry *ent;
|
||||
|
||||
@@ -962,7 +962,7 @@ static int store_object(
|
||||
struct object_entry *e;
|
||||
unsigned char hdr[96];
|
||||
struct object_id oid;
|
||||
unsigned long hdrlen, deltalen;
|
||||
size_t hdrlen, deltalen;
|
||||
struct git_hash_ctx c;
|
||||
git_zstream s;
|
||||
struct repo_config_values *cfg = repo_config_values(the_repository);
|
||||
@@ -998,13 +998,10 @@ static int store_object(
|
||||
|
||||
if (last && last->data.len && last->data.buf && last->depth < max_depth
|
||||
&& dat->len > the_hash_algo->rawsz) {
|
||||
size_t deltalen_st = 0;
|
||||
|
||||
delta_count_attempts_by_type[type]++;
|
||||
delta = diff_delta(last->data.buf, last->data.len,
|
||||
dat->buf, dat->len,
|
||||
&deltalen_st, dat->len - the_hash_algo->rawsz);
|
||||
deltalen = cast_size_t_to_ulong(deltalen_st);
|
||||
&deltalen, dat->len - the_hash_algo->rawsz);
|
||||
} else
|
||||
delta = NULL;
|
||||
|
||||
@@ -1240,10 +1237,9 @@ out:
|
||||
*/
|
||||
static void *gfi_unpack_entry(
|
||||
struct object_entry *oe,
|
||||
unsigned long *sizep)
|
||||
size_t *sizep)
|
||||
{
|
||||
enum object_type type;
|
||||
size_t size_st = 0;
|
||||
void *data;
|
||||
struct packed_git *p = all_packs[oe->pack_id];
|
||||
if (p == pack_data && p->pack_size < (pack_size + the_hash_algo->rawsz)) {
|
||||
@@ -1266,9 +1262,7 @@ static void *gfi_unpack_entry(
|
||||
*/
|
||||
p->pack_size = pack_size + the_hash_algo->rawsz;
|
||||
}
|
||||
data = unpack_entry(the_repository, p, oe->idx.offset, &type, &size_st);
|
||||
if (sizep)
|
||||
*sizep = cast_size_t_to_ulong(size_st);
|
||||
data = unpack_entry(the_repository, p, oe->idx.offset, &type, sizep);
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -1277,7 +1271,7 @@ static void load_tree(struct tree_entry *root)
|
||||
struct object_id *oid = &root->versions[1].oid;
|
||||
struct object_entry *myoe;
|
||||
struct tree_content *t;
|
||||
unsigned long size;
|
||||
size_t size;
|
||||
char *buf;
|
||||
const char *c;
|
||||
|
||||
@@ -1295,10 +1289,8 @@ static void load_tree(struct tree_entry *root)
|
||||
die(_("can't load tree %s"), oid_to_hex(oid));
|
||||
} else {
|
||||
enum object_type type;
|
||||
size_t size_st = 0;
|
||||
buf = odb_read_object(the_repository->objects, oid, &type,
|
||||
&size_st);
|
||||
size = cast_size_t_to_ulong(size_st);
|
||||
&size);
|
||||
if (!buf || type != OBJ_TREE)
|
||||
die(_("can't load tree %s"), oid_to_hex(oid));
|
||||
}
|
||||
@@ -2616,7 +2608,7 @@ static void file_change_deleteall(struct branch *b)
|
||||
b->num_notes = 0;
|
||||
}
|
||||
|
||||
static void parse_from_commit(struct branch *b, char *buf, unsigned long size)
|
||||
static void parse_from_commit(struct branch *b, char *buf, size_t size)
|
||||
{
|
||||
if (!buf || size < the_hash_algo->hexsz + 6)
|
||||
die(_("not a valid commit: %s"), oid_to_hex(&b->oid));
|
||||
@@ -2633,13 +2625,11 @@ static void parse_from_existing(struct branch *b)
|
||||
oidclr(&b->branch_tree.versions[0].oid, the_repository->hash_algo);
|
||||
oidclr(&b->branch_tree.versions[1].oid, the_repository->hash_algo);
|
||||
} else {
|
||||
unsigned long size;
|
||||
size_t size_st = 0;
|
||||
size_t size;
|
||||
char *buf;
|
||||
|
||||
buf = odb_read_object_peeled(the_repository->objects, &b->oid,
|
||||
OBJ_COMMIT, &size_st, &b->oid);
|
||||
size = cast_size_t_to_ulong(size_st);
|
||||
OBJ_COMMIT, &size, &b->oid);
|
||||
parse_from_commit(b, buf, size);
|
||||
free(buf);
|
||||
}
|
||||
@@ -2668,7 +2658,7 @@ static int parse_objectish(struct branch *b, const char *objectish)
|
||||
if (!oideq(&b->oid, &oe->idx.oid)) {
|
||||
oidcpy(&b->oid, &oe->idx.oid);
|
||||
if (oe->pack_id != MAX_PACK_ID) {
|
||||
unsigned long size;
|
||||
size_t size;
|
||||
char *buf = gfi_unpack_entry(oe, &size);
|
||||
parse_from_commit(b, buf, size);
|
||||
free(buf);
|
||||
@@ -3334,15 +3324,13 @@ static void cat_blob_write(const char *buf, unsigned long size)
|
||||
static void cat_blob(struct object_entry *oe, struct object_id *oid)
|
||||
{
|
||||
struct strbuf line = STRBUF_INIT;
|
||||
unsigned long size;
|
||||
size_t size;
|
||||
enum object_type type = 0;
|
||||
char *buf;
|
||||
|
||||
if (!oe || oe->pack_id == MAX_PACK_ID) {
|
||||
size_t size_st = 0;
|
||||
buf = odb_read_object(the_repository->objects, oid, &type,
|
||||
&size_st);
|
||||
size = cast_size_t_to_ulong(size_st);
|
||||
&size);
|
||||
} else {
|
||||
type = oe->type;
|
||||
buf = gfi_unpack_entry(oe, &size);
|
||||
@@ -3421,7 +3409,7 @@ static void parse_cat_blob(const char *p)
|
||||
static struct object_entry *dereference(struct object_entry *oe,
|
||||
struct object_id *oid)
|
||||
{
|
||||
unsigned long size;
|
||||
size_t size;
|
||||
char *buf = NULL;
|
||||
const unsigned hexsz = the_hash_algo->hexsz;
|
||||
|
||||
@@ -3450,10 +3438,8 @@ static struct object_entry *dereference(struct object_entry *oe,
|
||||
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_st);
|
||||
size = cast_size_t_to_ulong(size_st);
|
||||
&unused, &size);
|
||||
}
|
||||
if (!buf)
|
||||
die(_("can't load object %s"), oid_to_hex(oid));
|
||||
|
||||
@@ -353,21 +353,17 @@ static void index_commit_for_bitmap(struct commit *commit)
|
||||
|
||||
static void *get_delta(struct object_entry *entry)
|
||||
{
|
||||
unsigned long size, base_size;
|
||||
size_t delta_size;
|
||||
size_t 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_st);
|
||||
size = cast_size_t_to_ulong(size_st);
|
||||
&type, &size);
|
||||
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_st);
|
||||
base_size = cast_size_t_to_ulong(base_size_st);
|
||||
&base_size);
|
||||
if (!base_buf)
|
||||
die("unable to read %s",
|
||||
oid_to_hex(&DELTA(entry)->idx.oid));
|
||||
@@ -385,11 +381,11 @@ static void *get_delta(struct object_entry *entry)
|
||||
return delta_buf;
|
||||
}
|
||||
|
||||
static unsigned long do_compress(void **pptr, unsigned long size)
|
||||
static size_t do_compress(void **pptr, size_t size)
|
||||
{
|
||||
git_zstream stream;
|
||||
void *in, *out;
|
||||
unsigned long maxsize;
|
||||
size_t maxsize;
|
||||
struct repo_config_values *cfg = repo_config_values(the_repository);
|
||||
|
||||
git_deflate_init(&stream, cfg->pack_compression_level);
|
||||
@@ -515,7 +511,7 @@ static inline int oe_size_greater_than(struct packing_data *pack,
|
||||
static unsigned long write_no_reuse_object(struct hashfile *f, struct object_entry *entry,
|
||||
unsigned long limit, int usable_delta)
|
||||
{
|
||||
unsigned long size, datalen;
|
||||
size_t size, datalen;
|
||||
unsigned char header[MAX_PACK_OBJECT_HEADER],
|
||||
dheader[MAX_PACK_OBJECT_HEADER];
|
||||
unsigned hdrlen;
|
||||
@@ -534,11 +530,9 @@ static unsigned long write_no_reuse_object(struct hashfile *f, struct object_ent
|
||||
type = st->type;
|
||||
size = st->size;
|
||||
} else {
|
||||
size_t size_st = 0;
|
||||
buf = odb_read_object(the_repository->objects,
|
||||
&entry->idx.oid, &type,
|
||||
&size_st);
|
||||
size = cast_size_t_to_ulong(size_st);
|
||||
&size);
|
||||
if (!buf)
|
||||
die(_("unable to read %s"),
|
||||
oid_to_hex(&entry->idx.oid));
|
||||
@@ -2788,8 +2782,7 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,
|
||||
{
|
||||
struct object_entry *trg_entry = trg->entry;
|
||||
struct object_entry *src_entry = src->entry;
|
||||
unsigned long trg_size, src_size, sizediff, max_size, sz;
|
||||
size_t delta_size;
|
||||
size_t trg_size, src_size, delta_size, sizediff, max_size, sz;
|
||||
unsigned ref_depth;
|
||||
enum object_type type;
|
||||
void *delta_buf;
|
||||
@@ -2842,12 +2835,10 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,
|
||||
|
||||
/* 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_st);
|
||||
sz = cast_size_t_to_ulong(sz_st);
|
||||
&sz);
|
||||
packing_data_unlock(&to_pack);
|
||||
if (!trg->data)
|
||||
die(_("object %s cannot be read"),
|
||||
@@ -2859,12 +2850,10 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,
|
||||
*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_st);
|
||||
sz = cast_size_t_to_ulong(sz_st);
|
||||
&sz);
|
||||
packing_data_unlock(&to_pack);
|
||||
if (!src->data) {
|
||||
if (src_entry->preferred_base) {
|
||||
|
||||
@@ -699,15 +699,6 @@ static inline size_t st_left_shift(size_t a, unsigned shift)
|
||||
return a << shift;
|
||||
}
|
||||
|
||||
static inline unsigned long cast_size_t_to_ulong(size_t a)
|
||||
{
|
||||
if (a != (unsigned long)a)
|
||||
die("object too large to read on this platform: %"
|
||||
PRIuMAX" is cut off to %lu",
|
||||
(uintmax_t)a, (unsigned long)a);
|
||||
return (unsigned long)a;
|
||||
}
|
||||
|
||||
static inline uint32_t cast_size_t_to_uint32_t(size_t a)
|
||||
{
|
||||
if (a != (uint32_t)a)
|
||||
|
||||
@@ -18,7 +18,7 @@ static const char *usage_str[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static unsigned long do_compress(void **pptr, unsigned long size)
|
||||
static size_t do_compress(void **pptr, size_t size)
|
||||
{
|
||||
git_zstream stream;
|
||||
void *in, *out;
|
||||
@@ -48,8 +48,8 @@ static void write_ref_delta(struct hashfile *f,
|
||||
struct object_id *base)
|
||||
{
|
||||
unsigned char header[MAX_PACK_OBJECT_HEADER];
|
||||
unsigned long delta_size, compressed_size, hdrlen;
|
||||
size_t size, base_size, delta_size_st = 0;
|
||||
unsigned long compressed_size, hdrlen;
|
||||
size_t size, base_size, delta_size;
|
||||
enum object_type type;
|
||||
void *base_buf, *delta_buf;
|
||||
void *buf = odb_read_object(the_repository->objects,
|
||||
@@ -65,8 +65,7 @@ static void write_ref_delta(struct hashfile *f,
|
||||
die("unable to read %s", oid_to_hex(base));
|
||||
|
||||
delta_buf = diff_delta(base_buf, base_size,
|
||||
buf, size, &delta_size_st, 0);
|
||||
delta_size = cast_size_t_to_ulong(delta_size_st);
|
||||
buf, size, &delta_size, 0);
|
||||
|
||||
compressed_size = do_compress(&delta_buf, delta_size);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user