diffcore: widen struct diff_filespec.size to size_t

Continue the size_t evacuation. The struct field already receives
its writes from a size_t-shaped source (xsize_t(st.st_size),
strbuf.len, fill_textconv()'s return, odb_read_object_info_extended()
via oi.sizep), so on Windows it was already truncating anything
past 4 GiB silently on the strbuf and textconv paths and loudly
through cast_size_t_to_ulong() on the odb path. Switch the field
to size_t.

In diff_populate_filespec(), point oi.sizep at the field directly
and drop both cast_size_t_to_ulong() shims and the size_st bridge
they fed.

Downstream consumers that still read .size into unsigned long
locals will now silently narrow on Windows where the field exceeds
4 GiB. Each of those is its own follow-up; the writer side is the
prerequisite for ever putting a >4 GiB value in the field in the
first place.

Assisted-by: Opus 4.7
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
Johannes Schindelin
2026-06-05 19:38:13 +02:00
committed by Git for Windows Build Agent
parent eca45d90fb
commit 40a799cf1e
2 changed files with 2 additions and 5 deletions

View File

@@ -4734,9 +4734,8 @@ int diff_populate_filespec(struct repository *r,
}
}
else {
size_t size_st = 0;
struct object_info info = {
.sizep = &size_st
.sizep = &s->size
};
if (!(size_only || check_binary))
@@ -4758,7 +4757,6 @@ int diff_populate_filespec(struct repository *r,
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;
@@ -4773,7 +4771,6 @@ object_read:
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;
}