mirror of
https://github.com/git-for-windows/git.git
synced 2026-06-27 00:58:30 -05:00
diff: widen textconv_object() size out-param to size_t
Continue the size_t evacuation. textconv_object() fills its out-parameter from fill_textconv()'s size_t return through an unsigned long*; widen the API to match, then take advantage of the new shape where callers can. cat-file's 'c' and batch-mode 'c' branches lose their size_ul bridge variables (one site becomes a direct call, the other collapses an if/else into a single negated condition that reads as "try textconv, fall back to a raw read"). blame.c likewise drops the file_size_st bridge in fill_origin_blob() and hoists final_buf_size_st to bracket both branches in setup_scoreboard(). The latter keeps a cast_size_t_to_ulong() shim because struct blame_scoreboard.final_buf_size is still unsigned long; that field is its own topic. log.c just widens its local from unsigned long to size_t. Assisted-by: Opus 4.7 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
committed by
Git for Windows Build Agent
parent
9534688108
commit
eca45d90fb
@@ -202,11 +202,9 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
|
||||
|
||||
case 'c':
|
||||
{
|
||||
unsigned long size_ul = 0;
|
||||
int textconv_ret = textconv_object(the_repository, path,
|
||||
obj_context.mode, &oid, 1,
|
||||
&buf, &size_ul);
|
||||
size = size_ul;
|
||||
&buf, &size);
|
||||
if (textconv_ret)
|
||||
break;
|
||||
}
|
||||
@@ -448,12 +446,9 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d
|
||||
oid_to_hex(oid), data->rest);
|
||||
} else if (opt->transform_mode == 'c') {
|
||||
enum object_type type;
|
||||
unsigned long size_ul = 0;
|
||||
if (textconv_object(the_repository,
|
||||
data->rest, 0100644, oid,
|
||||
1, &contents, &size_ul))
|
||||
size = size_ul;
|
||||
else
|
||||
if (!textconv_object(the_repository,
|
||||
data->rest, 0100644, oid,
|
||||
1, &contents, &size))
|
||||
contents = odb_read_object(the_repository->objects,
|
||||
oid, &type, &size);
|
||||
if (!contents)
|
||||
|
||||
@@ -584,7 +584,7 @@ static int show_blob_object(const struct object_id *oid, struct rev_info *rev, c
|
||||
struct object_id oidc;
|
||||
struct object_context obj_context = {0};
|
||||
char *buf;
|
||||
unsigned long size;
|
||||
size_t size;
|
||||
|
||||
fflush(rev->diffopt.file);
|
||||
if (!rev->diffopt.flags.textconv_set_via_cmdline ||
|
||||
|
||||
21
lib/blame.c
21
lib/blame.c
@@ -240,7 +240,7 @@ static struct commit *fake_working_tree_commit(struct repository *r,
|
||||
struct stat st;
|
||||
const char *read_from;
|
||||
char *buf_ptr;
|
||||
unsigned long buf_len;
|
||||
size_t buf_len;
|
||||
|
||||
if (contents_from) {
|
||||
if (stat(contents_from, &st) < 0)
|
||||
@@ -1044,20 +1044,17 @@ static void fill_origin_blob(struct diff_options *opt,
|
||||
{
|
||||
if (!o->file.ptr) {
|
||||
enum object_type type;
|
||||
unsigned long file_size;
|
||||
size_t file_size;
|
||||
|
||||
(*num_read_blob)++;
|
||||
if (opt->flags.allow_textconv &&
|
||||
textconv_object(opt->repo, o->path, o->mode,
|
||||
&o->blob_oid, 1, &file->ptr, &file_size))
|
||||
;
|
||||
else {
|
||||
size_t file_size_st = 0;
|
||||
else
|
||||
file->ptr = odb_read_object(the_repository->objects,
|
||||
&o->blob_oid, &type,
|
||||
&file_size_st);
|
||||
file_size = cast_size_t_to_ulong(file_size_st);
|
||||
}
|
||||
&file_size);
|
||||
file->size = file_size;
|
||||
|
||||
if (!file->ptr)
|
||||
@@ -2886,22 +2883,20 @@ 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,
|
||||
&sb->final_buf_size))
|
||||
&final_buf_size_st))
|
||||
;
|
||||
else {
|
||||
size_t final_buf_size_st = 0;
|
||||
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 = cast_size_t_to_ulong(final_buf_size_st);
|
||||
|
||||
if (!sb->final_buf)
|
||||
die(_("cannot read blob %s for path %s"),
|
||||
|
||||
@@ -7997,7 +7997,7 @@ int textconv_object(struct repository *r,
|
||||
const struct object_id *oid,
|
||||
int oid_valid,
|
||||
char **buf,
|
||||
unsigned long *buf_size)
|
||||
size_t *buf_size)
|
||||
{
|
||||
struct diff_filespec *df;
|
||||
struct userdiff_driver *textconv;
|
||||
|
||||
@@ -762,7 +762,7 @@ int textconv_object(struct repository *repo,
|
||||
const char *path,
|
||||
unsigned mode,
|
||||
const struct object_id *oid, int oid_valid,
|
||||
char **buf, unsigned long *buf_size);
|
||||
char **buf, size_t *buf_size);
|
||||
|
||||
int parse_rename_score(const char **cp_p);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user