commit: widen the commit-buffer API to size_t

Continue the migration from `unsigned long` to `size_t`. The `size`
attribute of `struct commit_buffer` is fed either from
`odb_read_object()`'s return value (`size_t`, handled with
`cast_size_t_to_ulong()`) or from `strbuf.len` in
`fake_working_tree_commit()` (silently narrowed today). Widen the field
and a couple of function signatures together, drop the shim in
`repo_get_commit_buffer()`, and move the matching `unsigned long` locals
at the in-tree callers in commit.c (three sites), builtin/replace.c, and
builtin/stash.c (two sites). The remaining callers pass NULL or already
pass a size_t-compatible variable.

Assisted-by: Opus 4.7
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
Johannes Schindelin
2026-06-05 22:12:59 +02:00
parent f3aeae983a
commit fe5e428174
4 changed files with 19 additions and 14 deletions

View File

@@ -131,13 +131,15 @@ void free_commit_buffer_slab(struct buffer_slab *bs);
* Associate an object buffer with the commit. The ownership of the
* memory is handed over to the commit, and must be free()-able.
*/
void set_commit_buffer(struct repository *r, struct commit *, void *buffer, unsigned long size);
void set_commit_buffer(struct repository *r, struct commit *,
void *buffer, size_t size);
/*
* Get any cached object buffer associated with the commit. Returns NULL
* if none. The resulting memory should not be freed.
*/
const void *get_cached_commit_buffer(struct repository *, const struct commit *, unsigned long *size);
const void *get_cached_commit_buffer(struct repository *,
const struct commit *, size_t *size);
/*
* Get the commit's object contents, either from cache or by reading the object
@@ -146,7 +148,7 @@ const void *get_cached_commit_buffer(struct repository *, const struct commit *,
*/
const void *repo_get_commit_buffer(struct repository *r,
const struct commit *,
unsigned long *size);
size_t *size);
/*
* Tell the commit subsystem that we are done with a particular commit buffer.