@@ -1092,7 +1092,8 @@ static void prepare_merge_message(struct strbuf *merge_names, struct strbuf *mer
1092
1092
1093
1093
static struct commit_list * collect_parents (struct commit * head_commit ,
1094
1094
int * head_subsumed ,
1095
- int argc , const char * * argv )
1095
+ int argc , const char * * argv ,
1096
+ struct strbuf * merge_msg )
1096
1097
{
1097
1098
int i ;
1098
1099
struct commit_list * remoteheads = NULL ;
@@ -1108,7 +1109,20 @@ static struct commit_list *collect_parents(struct commit *head_commit,
1108
1109
remotes = & commit_list_insert (commit , remotes )-> next ;
1109
1110
}
1110
1111
1111
- return reduce_parents (head_commit , head_subsumed , remoteheads );
1112
+ remoteheads = reduce_parents (head_commit , head_subsumed , remoteheads );
1113
+
1114
+ if (merge_msg &&
1115
+ (!have_message || shortlog_len )) {
1116
+ struct strbuf merge_names = STRBUF_INIT ;
1117
+ struct commit_list * p ;
1118
+
1119
+ for (p = remoteheads ; p ; p = p -> next )
1120
+ merge_name (merge_remote_util (p -> item )-> name , & merge_names );
1121
+ prepare_merge_message (& merge_names , merge_msg );
1122
+ strbuf_release (& merge_names );
1123
+ }
1124
+
1125
+ return remoteheads ;
1112
1126
}
1113
1127
1114
1128
int cmd_merge (int argc , const char * * argv , const char * prefix )
@@ -1222,7 +1236,8 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
1222
1236
if (fast_forward == FF_NO )
1223
1237
die (_ ("Non-fast-forward commit does not make sense into "
1224
1238
"an empty head" ));
1225
- remoteheads = collect_parents (head_commit , & head_subsumed , argc , argv );
1239
+ remoteheads = collect_parents (head_commit , & head_subsumed ,
1240
+ argc , argv , NULL );
1226
1241
remote_head = remoteheads -> item ;
1227
1242
if (!remote_head )
1228
1243
die (_ ("%s - not something we can merge" ), argv [0 ]);
@@ -1248,7 +1263,8 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
1248
1263
head_arg = argv [1 ];
1249
1264
argv += 2 ;
1250
1265
argc -= 2 ;
1251
- remoteheads = collect_parents (head_commit , & head_subsumed , argc , argv );
1266
+ remoteheads = collect_parents (head_commit , & head_subsumed ,
1267
+ argc , argv , NULL );
1252
1268
} else {
1253
1269
/* We are invoked directly as the first-class UI. */
1254
1270
head_arg = "HEAD" ;
@@ -1258,16 +1274,8 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
1258
1274
* the standard merge summary message to be appended
1259
1275
* to the given message.
1260
1276
*/
1261
- remoteheads = collect_parents (head_commit , & head_subsumed , argc , argv );
1262
-
1263
- if (!have_message || shortlog_len ) {
1264
- struct strbuf merge_names = STRBUF_INIT ;
1265
-
1266
- for (p = remoteheads ; p ; p = p -> next )
1267
- merge_name (merge_remote_util (p -> item )-> name , & merge_names );
1268
- prepare_merge_message (& merge_names , & merge_msg );
1269
- strbuf_release (& merge_names );
1270
- }
1277
+ remoteheads = collect_parents (head_commit , & head_subsumed ,
1278
+ argc , argv , & merge_msg );
1271
1279
}
1272
1280
1273
1281
if (!head_commit || !argc )
0 commit comments