read-cache: stop truncating index blob sizes on Windows

Continue the size_t evacuation. read_blob_data_from_index() reads
the blob through the size_t odb_read_object() API but writes the
size back through an unsigned long out-parameter, silently
truncating anything past 4 GiB on Windows. Widen the out-parameter,
drop the cast_size_t_to_ulong() shim, and move the matching locals
in the two convert.c callers and the one in attr.c. Their
downstream consumers (gather_convert_stats() widened in the prior
commit and read_attr_from_buf() already size_t) take the new type
directly.

Assisted-by: Opus 4.7
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
Johannes Schindelin
2026-06-05 17:00:12 +02:00
committed by Git for Windows Build Agent
parent ec7073bbf1
commit fc044dac30
4 changed files with 6 additions and 6 deletions

View File

@@ -793,7 +793,7 @@ static struct attr_stack *read_attr_from_index(struct index_state *istate,
{
struct attr_stack *stack = NULL;
char *buf;
unsigned long size;
size_t size;
int sparse_dir_pos = -1;
if (!istate)

View File

@@ -141,7 +141,7 @@ const char *get_cached_convert_stats_ascii(struct index_state *istate,
const char *path)
{
const char *ret;
unsigned long sz;
size_t sz;
void *data = read_blob_data_from_index(istate, path, &sz);
ret = gather_convert_stats_ascii(data, sz);
free(data);
@@ -223,7 +223,7 @@ static void check_global_conv_flags_eol(const char *path,
static int has_crlf_in_index(struct index_state *istate, const char *path)
{
unsigned long sz;
size_t sz;
void *data;
const char *crp;
int has_crlf = 0;

View File

@@ -412,7 +412,7 @@ int chmod_index_entry(struct index_state *, struct cache_entry *ce, char flip);
int ce_same_name(const struct cache_entry *a, const struct cache_entry *b);
void set_object_name_for_intent_to_add_entry(struct cache_entry *ce);
int index_name_is_other(struct index_state *, const char *, int);
void *read_blob_data_from_index(struct index_state *, const char *, unsigned long *);
void *read_blob_data_from_index(struct index_state *, const char *, size_t *);
/* do stat comparison even if CE_VALID is true */
#define CE_MATCH_IGNORE_VALID 01

View File

@@ -3473,7 +3473,7 @@ int index_name_is_other(struct index_state *istate, const char *name,
}
void *read_blob_data_from_index(struct index_state *istate,
const char *path, unsigned long *size)
const char *path, size_t *size)
{
int pos, len;
size_t sz;
@@ -3504,7 +3504,7 @@ void *read_blob_data_from_index(struct index_state *istate,
return NULL;
}
if (size)
*size = cast_size_t_to_ulong(sz);
*size = sz;
return data;
}