Skip to content

Commit b4d48c8

Browse files
dschoGit for Windows Build Agent
authored andcommitted
Merge branch 'size-t/diff'
2 parents dae643f + 4af14ee commit b4d48c8

13 files changed

Lines changed: 39 additions & 56 deletions

attr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,7 @@ static struct attr_stack *read_attr_from_index(struct index_state *istate,
793793
{
794794
struct attr_stack *stack = NULL;
795795
char *buf;
796-
unsigned long size;
796+
size_t size;
797797
int sparse_dir_pos = -1;
798798

799799
if (!istate)

blame.c

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ static struct commit *fake_working_tree_commit(struct repository *r,
238238
struct stat st;
239239
const char *read_from;
240240
char *buf_ptr;
241-
unsigned long buf_len;
241+
size_t buf_len;
242242

243243
if (contents_from) {
244244
if (stat(contents_from, &st) < 0)
@@ -1034,20 +1034,17 @@ static void fill_origin_blob(struct diff_options *opt,
10341034
{
10351035
if (!o->file.ptr) {
10361036
enum object_type type;
1037-
unsigned long file_size;
1037+
size_t file_size;
10381038

10391039
(*num_read_blob)++;
10401040
if (opt->flags.allow_textconv &&
10411041
textconv_object(opt->repo, o->path, o->mode,
10421042
&o->blob_oid, 1, &file->ptr, &file_size))
10431043
;
1044-
else {
1045-
size_t file_size_st = 0;
1044+
else
10461045
file->ptr = odb_read_object(the_repository->objects,
10471046
&o->blob_oid, &type,
1048-
&file_size_st);
1049-
file_size = cast_size_t_to_ulong(file_size_st);
1050-
}
1047+
&file_size);
10511048
file->size = file_size;
10521049

10531050
if (!file->ptr)
@@ -2864,22 +2861,20 @@ void setup_scoreboard(struct blame_scoreboard *sb,
28642861
sb->final_buf_size = o->file.size;
28652862
}
28662863
else {
2864+
size_t final_buf_size_st = 0;
28672865
o = get_origin(sb->final, sb->path);
28682866
if (fill_blob_sha1_and_mode(sb->repo, o))
28692867
die(_("no such path %s in %s"), sb->path, final_commit_name);
28702868

28712869
if (sb->revs->diffopt.flags.allow_textconv &&
28722870
textconv_object(sb->repo, sb->path, o->mode, &o->blob_oid, 1, (char **) &sb->final_buf,
2873-
&sb->final_buf_size))
2871+
&final_buf_size_st))
28742872
;
2875-
else {
2876-
size_t final_buf_size_st = 0;
2873+
else
28772874
sb->final_buf = odb_read_object(the_repository->objects,
28782875
&o->blob_oid, &type,
28792876
&final_buf_size_st);
2880-
sb->final_buf_size =
2881-
cast_size_t_to_ulong(final_buf_size_st);
2882-
}
2877+
sb->final_buf_size = cast_size_t_to_ulong(final_buf_size_st);
28832878

28842879
if (!sb->final_buf)
28852880
die(_("cannot read blob %s for path %s"),

builtin/cat-file.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,9 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
186186

187187
case 'c':
188188
{
189-
unsigned long size_ul = 0;
190189
int textconv_ret = textconv_object(the_repository, path,
191190
obj_context.mode, &oid, 1,
192-
&buf, &size_ul);
193-
size = size_ul;
191+
&buf, &size);
194192
if (textconv_ret)
195193
break;
196194
}
@@ -413,12 +411,9 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d
413411
oid_to_hex(oid), data->rest);
414412
} else if (opt->transform_mode == 'c') {
415413
enum object_type type;
416-
unsigned long size_ul = 0;
417-
if (textconv_object(the_repository,
418-
data->rest, 0100644, oid,
419-
1, &contents, &size_ul))
420-
size = size_ul;
421-
else
414+
if (!textconv_object(the_repository,
415+
data->rest, 0100644, oid,
416+
1, &contents, &size))
422417
contents = odb_read_object(the_repository->objects,
423418
oid, &type, &size);
424419
if (!contents)

builtin/log.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ static int show_blob_object(const struct object_id *oid, struct rev_info *rev, c
584584
struct object_id oidc;
585585
struct object_context obj_context = {0};
586586
char *buf;
587-
unsigned long size;
587+
size_t size;
588588

589589
fflush(rev->diffopt.file);
590590
if (!rev->diffopt.flags.textconv_set_via_cmdline ||

combine-diff.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ static struct lline *coalesce_lines(struct lline *base, int *lenbase,
304304

305305
static char *grab_blob(struct repository *r,
306306
const struct object_id *oid, unsigned int mode,
307-
unsigned long *size, struct userdiff_driver *textconv,
307+
size_t *size, struct userdiff_driver *textconv,
308308
const char *path)
309309
{
310310
char *blob;
@@ -325,9 +325,7 @@ static char *grab_blob(struct repository *r,
325325
*size = fill_textconv(r, textconv, df, &blob);
326326
free_filespec(df);
327327
} else {
328-
size_t size_st = 0;
329-
blob = odb_read_object(r->objects, oid, &type, &size_st);
330-
*size = cast_size_t_to_ulong(size_st);
328+
blob = odb_read_object(r->objects, oid, &type, size);
331329
if (!blob)
332330
die(_("unable to read %s"), oid_to_hex(oid));
333331
if (type != OBJ_BLOB)
@@ -431,7 +429,7 @@ static void combine_diff(struct repository *r,
431429
xdemitconf_t xecfg;
432430
mmfile_t parent_file;
433431
struct combine_diff_state state;
434-
unsigned long sz;
432+
size_t sz;
435433

436434
if (result_deleted)
437435
return; /* result deleted */
@@ -1015,7 +1013,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
10151013
struct rev_info *rev)
10161014
{
10171015
struct diff_options *opt = &rev->diffopt;
1018-
unsigned long result_size, cnt, lno;
1016+
size_t result_size, cnt, lno;
10191017
int result_deleted = 0;
10201018
char *result, *cp;
10211019
struct sline *sline; /* survived lines */
@@ -1134,7 +1132,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
11341132
is_binary = buffer_is_binary(result, result_size);
11351133
for (i = 0; !is_binary && i < num_parent; i++) {
11361134
char *buf;
1137-
unsigned long size;
1135+
size_t size;
11381136
buf = grab_blob(opt->repo,
11391137
&elem->parent[i].oid,
11401138
elem->parent[i].mode,

convert.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ static int convert_is_binary(const struct text_stat *stats)
102102
return 0;
103103
}
104104

105-
static unsigned int gather_convert_stats(const char *data, unsigned long size)
105+
static unsigned int gather_convert_stats(const char *data, size_t size)
106106
{
107107
struct text_stat stats;
108108
int ret = 0;
@@ -119,7 +119,7 @@ static unsigned int gather_convert_stats(const char *data, unsigned long size)
119119
return ret;
120120
}
121121

122-
static const char *gather_convert_stats_ascii(const char *data, unsigned long size)
122+
static const char *gather_convert_stats_ascii(const char *data, size_t size)
123123
{
124124
unsigned int convert_stats = gather_convert_stats(data, size);
125125

@@ -141,7 +141,7 @@ const char *get_cached_convert_stats_ascii(struct index_state *istate,
141141
const char *path)
142142
{
143143
const char *ret;
144-
unsigned long sz;
144+
size_t sz;
145145
void *data = read_blob_data_from_index(istate, path, &sz);
146146
ret = gather_convert_stats_ascii(data, sz);
147147
free(data);
@@ -223,7 +223,7 @@ static void check_global_conv_flags_eol(const char *path,
223223

224224
static int has_crlf_in_index(struct index_state *istate, const char *path)
225225
{
226-
unsigned long sz;
226+
size_t sz;
227227
void *data;
228228
const char *crp;
229229
int has_crlf = 0;

diff.c

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3606,8 +3606,8 @@ static int checkdiff_consume(void *priv, char *line, unsigned long len)
36063606
}
36073607

36083608
static unsigned char *deflate_it(char *data,
3609-
unsigned long size,
3610-
unsigned long *result_size)
3609+
size_t size,
3610+
size_t *result_size)
36113611
{
36123612
size_t bound;
36133613
unsigned char *deflated;
@@ -3636,22 +3636,20 @@ static void emit_binary_diff_body(struct diff_options *o,
36363636
void *delta;
36373637
void *deflated;
36383638
void *data;
3639-
unsigned long orig_size;
3640-
unsigned long delta_size;
3641-
unsigned long deflate_size;
3642-
unsigned long data_size;
3639+
size_t orig_size;
3640+
size_t delta_size;
3641+
size_t deflate_size;
3642+
size_t data_size;
36433643

36443644
/* We could do deflated delta, or we could do just deflated two,
36453645
* whichever is smaller.
36463646
*/
36473647
delta = NULL;
36483648
deflated = deflate_it(two->ptr, two->size, &deflate_size);
36493649
if (one->size && two->size) {
3650-
size_t delta_size_st = 0;
36513650
delta = diff_delta(one->ptr, one->size,
36523651
two->ptr, two->size,
3653-
&delta_size_st, deflate_size);
3654-
delta_size = cast_size_t_to_ulong(delta_size_st);
3652+
&delta_size, deflate_size);
36553653
if (delta) {
36563654
void *to_free = delta;
36573655
orig_size = delta_size;
@@ -4597,9 +4595,8 @@ int diff_populate_filespec(struct repository *r,
45974595
}
45984596
}
45994597
else {
4600-
size_t size_st = 0;
46014598
struct object_info info = {
4602-
.sizep = &size_st
4599+
.sizep = &s->size
46034600
};
46044601

46054602
if (!(size_only || check_binary))
@@ -4621,7 +4618,6 @@ int diff_populate_filespec(struct repository *r,
46214618
die("unable to read %s", oid_to_hex(&s->oid));
46224619

46234620
object_read:
4624-
s->size = cast_size_t_to_ulong(size_st);
46254621
if (size_only || check_binary) {
46264622
if (size_only)
46274623
return 0;
@@ -4636,7 +4632,6 @@ int diff_populate_filespec(struct repository *r,
46364632
if (odb_read_object_info_extended(r->objects, &s->oid, &info,
46374633
OBJECT_INFO_LOOKUP_REPLACE))
46384634
die("unable to read %s", oid_to_hex(&s->oid));
4639-
s->size = cast_size_t_to_ulong(size_st);
46404635
}
46414636
s->should_free = 1;
46424637
}
@@ -7847,7 +7842,7 @@ int textconv_object(struct repository *r,
78477842
const struct object_id *oid,
78487843
int oid_valid,
78497844
char **buf,
7850-
unsigned long *buf_size)
7845+
size_t *buf_size)
78517846
{
78527847
struct diff_filespec *df;
78537848
struct userdiff_driver *textconv;

diff.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,7 @@ int textconv_object(struct repository *repo,
757757
const char *path,
758758
unsigned mode,
759759
const struct object_id *oid, int oid_valid,
760-
char **buf, unsigned long *buf_size);
760+
char **buf, size_t *buf_size);
761761

762762
int parse_rename_score(const char **cp_p);
763763

diffcore.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ struct diff_filespec {
5454
char *path;
5555
void *data;
5656
void *cnt_data;
57-
unsigned long size;
57+
size_t size;
5858
int count; /* Reference count */
5959
int rename_used; /* Count of rename users */
6060
unsigned short mode; /* file mode */

read-cache-ll.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ int chmod_index_entry(struct index_state *, struct cache_entry *ce, char flip);
411411
int ce_same_name(const struct cache_entry *a, const struct cache_entry *b);
412412
void set_object_name_for_intent_to_add_entry(struct cache_entry *ce);
413413
int index_name_is_other(struct index_state *, const char *, int);
414-
void *read_blob_data_from_index(struct index_state *, const char *, unsigned long *);
414+
void *read_blob_data_from_index(struct index_state *, const char *, size_t *);
415415

416416
/* do stat comparison even if CE_VALID is true */
417417
#define CE_MATCH_IGNORE_VALID 01

0 commit comments

Comments
 (0)