@@ -2127,6 +2127,7 @@ static int handle_content_merge(struct merge_options *opt,
2127
2127
const struct version_info * b ,
2128
2128
const char * pathnames [3 ],
2129
2129
const int extra_marker_size ,
2130
+ const int record_object ,
2130
2131
struct version_info * result )
2131
2132
{
2132
2133
/*
@@ -2214,7 +2215,7 @@ static int handle_content_merge(struct merge_options *opt,
2214
2215
ret = -1 ;
2215
2216
}
2216
2217
2217
- if (!ret &&
2218
+ if (!ret && record_object &&
2218
2219
write_object_file (result_buf .ptr , result_buf .size ,
2219
2220
OBJ_BLOB , & result -> oid )) {
2220
2221
path_msg (opt , ERROR_OBJECT_WRITE_FAILED , 0 ,
@@ -2897,6 +2898,7 @@ static int process_renames(struct merge_options *opt,
2897
2898
struct version_info merged ;
2898
2899
struct conflict_info * base , * side1 , * side2 ;
2899
2900
unsigned was_binary_blob = 0 ;
2901
+ const int record_object = true;
2900
2902
2901
2903
pathnames [0 ] = oldpath ;
2902
2904
pathnames [1 ] = newpath ;
@@ -2947,6 +2949,7 @@ static int process_renames(struct merge_options *opt,
2947
2949
& side2 -> stages [2 ],
2948
2950
pathnames ,
2949
2951
1 + 2 * opt -> priv -> call_depth ,
2952
+ record_object ,
2950
2953
& merged );
2951
2954
if (clean_merge < 0 )
2952
2955
return -1 ;
@@ -3061,6 +3064,7 @@ static int process_renames(struct merge_options *opt,
3061
3064
3062
3065
struct conflict_info * base , * side1 , * side2 ;
3063
3066
int clean ;
3067
+ const int record_object = true;
3064
3068
3065
3069
pathnames [0 ] = oldpath ;
3066
3070
pathnames [other_source_index ] = oldpath ;
@@ -3080,6 +3084,7 @@ static int process_renames(struct merge_options *opt,
3080
3084
& side2 -> stages [2 ],
3081
3085
pathnames ,
3082
3086
1 + 2 * opt -> priv -> call_depth ,
3087
+ record_object ,
3083
3088
& merged );
3084
3089
if (clean < 0 )
3085
3090
return -1 ;
@@ -3931,9 +3936,12 @@ static int write_completed_directory(struct merge_options *opt,
3931
3936
* Write out the tree to the git object directory, and also
3932
3937
* record the mode and oid in dir_info->result.
3933
3938
*/
3939
+ int record_tree = (!opt -> mergeability_only ||
3940
+ opt -> priv -> call_depth );
3934
3941
dir_info -> is_null = 0 ;
3935
3942
dir_info -> result .mode = S_IFDIR ;
3936
- if (write_tree (& dir_info -> result .oid , & info -> versions , offset ,
3943
+ if (record_tree &&
3944
+ write_tree (& dir_info -> result .oid , & info -> versions , offset ,
3937
3945
opt -> repo -> hash_algo -> rawsz ) < 0 )
3938
3946
ret = -1 ;
3939
3947
}
@@ -4231,10 +4239,13 @@ static int process_entry(struct merge_options *opt,
4231
4239
struct version_info * o = & ci -> stages [0 ];
4232
4240
struct version_info * a = & ci -> stages [1 ];
4233
4241
struct version_info * b = & ci -> stages [2 ];
4242
+ int record_object = (!opt -> mergeability_only ||
4243
+ opt -> priv -> call_depth );
4234
4244
4235
4245
clean_merge = handle_content_merge (opt , path , o , a , b ,
4236
4246
ci -> pathnames ,
4237
4247
opt -> priv -> call_depth * 2 ,
4248
+ record_object ,
4238
4249
& merged_file );
4239
4250
if (clean_merge < 0 )
4240
4251
return -1 ;
@@ -4395,6 +4406,8 @@ static int process_entries(struct merge_options *opt,
4395
4406
STRING_LIST_INIT_NODUP ,
4396
4407
NULL , 0 };
4397
4408
int ret = 0 ;
4409
+ const int record_tree = (!opt -> mergeability_only ||
4410
+ opt -> priv -> call_depth );
4398
4411
4399
4412
trace2_region_enter ("merge" , "process_entries setup" , opt -> repo );
4400
4413
if (strmap_empty (& opt -> priv -> paths )) {
@@ -4454,6 +4467,12 @@ static int process_entries(struct merge_options *opt,
4454
4467
ret = -1 ;
4455
4468
goto cleanup ;
4456
4469
};
4470
+ if (!ci -> merged .clean && opt -> mergeability_only &&
4471
+ !opt -> priv -> call_depth ) {
4472
+ ret = 0 ;
4473
+ goto cleanup ;
4474
+ }
4475
+
4457
4476
}
4458
4477
}
4459
4478
trace2_region_leave ("merge" , "processing" , opt -> repo );
@@ -4468,7 +4487,8 @@ static int process_entries(struct merge_options *opt,
4468
4487
fflush (stdout );
4469
4488
BUG ("dir_metadata accounting completely off; shouldn't happen" );
4470
4489
}
4471
- if (write_tree (result_oid , & dir_metadata .versions , 0 ,
4490
+ if (record_tree &&
4491
+ write_tree (result_oid , & dir_metadata .versions , 0 ,
4472
4492
opt -> repo -> hash_algo -> rawsz ) < 0 )
4473
4493
ret = -1 ;
4474
4494
cleanup :
@@ -4715,6 +4735,8 @@ void merge_display_update_messages(struct merge_options *opt,
4715
4735
4716
4736
if (opt -> record_conflict_msgs_as_headers )
4717
4737
BUG ("Either display conflict messages or record them as headers, not both" );
4738
+ if (opt -> mergeability_only )
4739
+ BUG ("Displaying conflict messages incompatible with mergeability-only checks" );
4718
4740
4719
4741
trace2_region_enter ("merge" , "display messages" , opt -> repo );
4720
4742
@@ -5171,10 +5193,12 @@ static void merge_ort_nonrecursive_internal(struct merge_options *opt,
5171
5193
result -> path_messages = & opt -> priv -> conflicts ;
5172
5194
5173
5195
if (result -> clean >= 0 ) {
5174
- result -> tree = parse_tree_indirect (& working_tree_oid );
5175
- if (!result -> tree )
5176
- die (_ ("unable to read tree (%s)" ),
5177
- oid_to_hex (& working_tree_oid ));
5196
+ if (!opt -> mergeability_only ) {
5197
+ result -> tree = parse_tree_indirect (& working_tree_oid );
5198
+ if (!result -> tree )
5199
+ die (_ ("unable to read tree (%s)" ),
5200
+ oid_to_hex (& working_tree_oid ));
5201
+ }
5178
5202
/* existence of conflicted entries implies unclean */
5179
5203
result -> clean &= strmap_empty (& opt -> priv -> conflicted );
5180
5204
}
0 commit comments