@@ -573,7 +573,7 @@ static int fill_mmfile(struct repository *r, mmfile_t *mf,
573
573
mf -> size = 0 ;
574
574
return 0 ;
575
575
}
576
- else if (diff_populate_filespec (r , one , 0 ))
576
+ else if (diff_populate_filespec (r , one , NULL ))
577
577
return -1 ;
578
578
579
579
mf -> ptr = one -> data ;
@@ -585,9 +585,13 @@ static int fill_mmfile(struct repository *r, mmfile_t *mf,
585
585
static unsigned long diff_filespec_size (struct repository * r ,
586
586
struct diff_filespec * one )
587
587
{
588
+ struct diff_populate_filespec_options dpf_options = {
589
+ .check_size_only = 1 ,
590
+ };
591
+
588
592
if (!DIFF_FILE_VALID (one ))
589
593
return 0 ;
590
- diff_populate_filespec (r , one , CHECK_SIZE_ONLY );
594
+ diff_populate_filespec (r , one , & dpf_options );
591
595
return one -> size ;
592
596
}
593
597
@@ -3020,6 +3024,9 @@ static void show_dirstat(struct diff_options *options)
3020
3024
struct diff_filepair * p = q -> queue [i ];
3021
3025
const char * name ;
3022
3026
unsigned long copied , added , damage ;
3027
+ struct diff_populate_filespec_options dpf_options = {
3028
+ .check_size_only = 1 ,
3029
+ };
3023
3030
3024
3031
name = p -> two -> path ? p -> two -> path : p -> one -> path ;
3025
3032
@@ -3047,19 +3054,19 @@ static void show_dirstat(struct diff_options *options)
3047
3054
}
3048
3055
3049
3056
if (DIFF_FILE_VALID (p -> one ) && DIFF_FILE_VALID (p -> two )) {
3050
- diff_populate_filespec (options -> repo , p -> one , 0 );
3051
- diff_populate_filespec (options -> repo , p -> two , 0 );
3057
+ diff_populate_filespec (options -> repo , p -> one , NULL );
3058
+ diff_populate_filespec (options -> repo , p -> two , NULL );
3052
3059
diffcore_count_changes (options -> repo ,
3053
3060
p -> one , p -> two , NULL , NULL ,
3054
3061
& copied , & added );
3055
3062
diff_free_filespec_data (p -> one );
3056
3063
diff_free_filespec_data (p -> two );
3057
3064
} else if (DIFF_FILE_VALID (p -> one )) {
3058
- diff_populate_filespec (options -> repo , p -> one , CHECK_SIZE_ONLY );
3065
+ diff_populate_filespec (options -> repo , p -> one , & dpf_options );
3059
3066
copied = added = 0 ;
3060
3067
diff_free_filespec_data (p -> one );
3061
3068
} else if (DIFF_FILE_VALID (p -> two )) {
3062
- diff_populate_filespec (options -> repo , p -> two , CHECK_SIZE_ONLY );
3069
+ diff_populate_filespec (options -> repo , p -> two , & dpf_options );
3063
3070
copied = 0 ;
3064
3071
added = p -> two -> size ;
3065
3072
diff_free_filespec_data (p -> two );
@@ -3339,13 +3346,17 @@ static void emit_binary_diff(struct diff_options *o,
3339
3346
int diff_filespec_is_binary (struct repository * r ,
3340
3347
struct diff_filespec * one )
3341
3348
{
3349
+ struct diff_populate_filespec_options dpf_options = {
3350
+ .check_binary = 1 ,
3351
+ };
3352
+
3342
3353
if (one -> is_binary == -1 ) {
3343
3354
diff_filespec_load_driver (one , r -> index );
3344
3355
if (one -> driver -> binary != -1 )
3345
3356
one -> is_binary = one -> driver -> binary ;
3346
3357
else {
3347
3358
if (!one -> data && DIFF_FILE_VALID (one ))
3348
- diff_populate_filespec (r , one , CHECK_BINARY );
3359
+ diff_populate_filespec (r , one , & dpf_options );
3349
3360
if (one -> is_binary == -1 && one -> data )
3350
3361
one -> is_binary = buffer_is_binary (one -> data ,
3351
3362
one -> size );
@@ -3677,8 +3688,8 @@ static void builtin_diffstat(const char *name_a, const char *name_b,
3677
3688
}
3678
3689
3679
3690
else if (complete_rewrite ) {
3680
- diff_populate_filespec (o -> repo , one , 0 );
3681
- diff_populate_filespec (o -> repo , two , 0 );
3691
+ diff_populate_filespec (o -> repo , one , NULL );
3692
+ diff_populate_filespec (o -> repo , two , NULL );
3682
3693
data -> deleted = count_lines (one -> data , one -> size );
3683
3694
data -> added = count_lines (two -> data , two -> size );
3684
3695
}
@@ -3914,9 +3925,10 @@ static int diff_populate_gitlink(struct diff_filespec *s, int size_only)
3914
3925
*/
3915
3926
int diff_populate_filespec (struct repository * r ,
3916
3927
struct diff_filespec * s ,
3917
- unsigned int flags )
3928
+ const struct diff_populate_filespec_options * options )
3918
3929
{
3919
- int size_only = flags & CHECK_SIZE_ONLY ;
3930
+ int size_only = options ? options -> check_size_only : 0 ;
3931
+ int check_binary = options ? options -> check_binary : 0 ;
3920
3932
int err = 0 ;
3921
3933
int conv_flags = global_conv_flags_eol ;
3922
3934
/*
@@ -3986,7 +3998,7 @@ int diff_populate_filespec(struct repository *r,
3986
3998
* opening the file and inspecting the contents, this
3987
3999
* is probably fine.
3988
4000
*/
3989
- if (( flags & CHECK_BINARY ) &&
4001
+ if (check_binary &&
3990
4002
s -> size > big_file_threshold && s -> is_binary == -1 ) {
3991
4003
s -> is_binary = 1 ;
3992
4004
return 0 ;
@@ -4012,7 +4024,7 @@ int diff_populate_filespec(struct repository *r,
4012
4024
}
4013
4025
else {
4014
4026
enum object_type type ;
4015
- if (size_only || ( flags & CHECK_BINARY ) ) {
4027
+ if (size_only || check_binary ) {
4016
4028
type = oid_object_info (r , & s -> oid , & s -> size );
4017
4029
if (type < 0 )
4018
4030
die ("unable to read %s" ,
@@ -4141,7 +4153,7 @@ static struct diff_tempfile *prepare_temp_file(struct repository *r,
4141
4153
return temp ;
4142
4154
}
4143
4155
else {
4144
- if (diff_populate_filespec (r , one , 0 ))
4156
+ if (diff_populate_filespec (r , one , NULL ))
4145
4157
die ("cannot read data blob for %s" , one -> path );
4146
4158
prep_temp_blob (r -> index , name , temp ,
4147
4159
one -> data , one -> size ,
@@ -6407,16 +6419,20 @@ static int diff_filespec_is_identical(struct repository *r,
6407
6419
{
6408
6420
if (S_ISGITLINK (one -> mode ))
6409
6421
return 0 ;
6410
- if (diff_populate_filespec (r , one , 0 ))
6422
+ if (diff_populate_filespec (r , one , NULL ))
6411
6423
return 0 ;
6412
- if (diff_populate_filespec (r , two , 0 ))
6424
+ if (diff_populate_filespec (r , two , NULL ))
6413
6425
return 0 ;
6414
6426
return !memcmp (one -> data , two -> data , one -> size );
6415
6427
}
6416
6428
6417
6429
static int diff_filespec_check_stat_unmatch (struct repository * r ,
6418
6430
struct diff_filepair * p )
6419
6431
{
6432
+ struct diff_populate_filespec_options dpf_options = {
6433
+ .check_size_only = 1 ,
6434
+ };
6435
+
6420
6436
if (p -> done_skip_stat_unmatch )
6421
6437
return p -> skip_stat_unmatch_result ;
6422
6438
@@ -6439,8 +6455,8 @@ static int diff_filespec_check_stat_unmatch(struct repository *r,
6439
6455
!DIFF_FILE_VALID (p -> two ) ||
6440
6456
(p -> one -> oid_valid && p -> two -> oid_valid ) ||
6441
6457
(p -> one -> mode != p -> two -> mode ) ||
6442
- diff_populate_filespec (r , p -> one , CHECK_SIZE_ONLY ) ||
6443
- diff_populate_filespec (r , p -> two , CHECK_SIZE_ONLY ) ||
6458
+ diff_populate_filespec (r , p -> one , & dpf_options ) ||
6459
+ diff_populate_filespec (r , p -> two , & dpf_options ) ||
6444
6460
(p -> one -> size != p -> two -> size ) ||
6445
6461
!diff_filespec_is_identical (r , p -> one , p -> two )) /* (2) */
6446
6462
p -> skip_stat_unmatch_result = 1 ;
@@ -6770,7 +6786,7 @@ size_t fill_textconv(struct repository *r,
6770
6786
* outbuf = "" ;
6771
6787
return 0 ;
6772
6788
}
6773
- if (diff_populate_filespec (r , df , 0 ))
6789
+ if (diff_populate_filespec (r , df , NULL ))
6774
6790
die ("unable to read files to diff" );
6775
6791
* outbuf = df -> data ;
6776
6792
return df -> size ;
0 commit comments