@@ -113,7 +113,7 @@ struct rebase_options {
113
113
int autostash ;
114
114
int committer_date_is_author_date ;
115
115
int ignore_date ;
116
- char * cmd ;
116
+ struct string_list exec ;
117
117
int allow_empty_message ;
118
118
int rebase_merges , rebase_cousins ;
119
119
char * strategy , * strategy_opts ;
@@ -131,6 +131,7 @@ struct rebase_options {
131
131
.default_backend = "merge", \
132
132
.flags = REBASE_NO_QUIET, \
133
133
.git_am_opts = STRVEC_INIT, \
134
+ .exec = STRING_LIST_INIT_NODUP, \
134
135
.git_format_patch_opt = STRBUF_INIT, \
135
136
.fork_point = -1, \
136
137
}
@@ -243,25 +244,13 @@ static int init_basic_state(struct replay_opts *opts, const char *head_name,
243
244
return write_basic_state (opts , head_name , onto , orig_head );
244
245
}
245
246
246
- static void split_exec_commands (const char * cmd , struct string_list * commands )
247
- {
248
- if (cmd && * cmd ) {
249
- string_list_split (commands , cmd , '\n' , -1 );
250
-
251
- /* rebase.c adds a new line to cmd after every command,
252
- * so here the last command is always empty */
253
- string_list_remove_empty_items (commands , 0 );
254
- }
255
- }
256
-
257
247
static int do_interactive_rebase (struct rebase_options * opts , unsigned flags )
258
248
{
259
249
int ret ;
260
250
char * revisions = NULL , * shortrevisions = NULL ;
261
251
struct strvec make_script_args = STRVEC_INIT ;
262
252
struct todo_list todo_list = TODO_LIST_INIT ;
263
253
struct replay_opts replay = get_replay_opts (opts );
264
- struct string_list commands = STRING_LIST_INIT_DUP ;
265
254
266
255
if (get_revision_ranges (opts -> upstream , opts -> onto , & opts -> orig_head -> object .oid ,
267
256
& revisions , & shortrevisions ))
@@ -297,14 +286,12 @@ static int do_interactive_rebase(struct rebase_options *opts, unsigned flags)
297
286
& todo_list ))
298
287
BUG ("unusable todo list" );
299
288
300
- split_exec_commands (opts -> cmd , & commands );
301
289
ret = complete_action (the_repository , & replay , flags ,
302
290
shortrevisions , opts -> onto_name , opts -> onto ,
303
- & opts -> orig_head -> object .oid , & commands ,
291
+ & opts -> orig_head -> object .oid , & opts -> exec ,
304
292
opts -> autosquash , opts -> update_refs , & todo_list );
305
293
}
306
294
307
- string_list_clear (& commands , 0 );
308
295
free (revisions );
309
296
free (shortrevisions );
310
297
todo_list_release (& todo_list );
@@ -1032,7 +1019,6 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1032
1019
struct object_id branch_base ;
1033
1020
int ignore_whitespace = 0 ;
1034
1021
const char * gpg_sign = NULL ;
1035
- struct string_list exec = STRING_LIST_INIT_NODUP ;
1036
1022
const char * rebase_merges = NULL ;
1037
1023
struct string_list strategy_options = STRING_LIST_INIT_NODUP ;
1038
1024
struct object_id squash_onto ;
@@ -1127,7 +1113,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1127
1113
N_ ("GPG-sign commits" ),
1128
1114
PARSE_OPT_OPTARG , NULL , (intptr_t ) "" },
1129
1115
OPT_AUTOSTASH (& options .autostash ),
1130
- OPT_STRING_LIST ('x' , "exec" , & exec , N_ ("exec" ),
1116
+ OPT_STRING_LIST ('x' , "exec" , & options . exec , N_ ("exec" ),
1131
1117
N_ ("add exec lines after each commit of the "
1132
1118
"editable list" )),
1133
1119
OPT_BOOL_F (0 , "allow-empty-message" ,
@@ -1250,7 +1236,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1250
1236
if (trace2_is_enabled ()) {
1251
1237
if (is_merge (& options ))
1252
1238
trace2_cmd_mode ("interactive" );
1253
- else if (exec .nr )
1239
+ else if (options . exec .nr )
1254
1240
trace2_cmd_mode ("interactive-exec" );
1255
1241
else
1256
1242
trace2_cmd_mode (action_names [options .action ]);
@@ -1378,7 +1364,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1378
1364
1379
1365
if ((options .flags & REBASE_INTERACTIVE_EXPLICIT ) ||
1380
1366
(options .action != ACTION_NONE ) ||
1381
- (exec .nr > 0 ) ||
1367
+ (options . exec .nr > 0 ) ||
1382
1368
options .autosquash ) {
1383
1369
allow_preemptive_ff = 0 ;
1384
1370
}
@@ -1402,8 +1388,8 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1402
1388
}
1403
1389
}
1404
1390
1405
- for (i = 0 ; i < exec .nr ; i ++ )
1406
- if (check_exec_cmd (exec .items [i ].string ))
1391
+ for (i = 0 ; i < options . exec .nr ; i ++ )
1392
+ if (check_exec_cmd (options . exec .items [i ].string ))
1407
1393
exit (1 );
1408
1394
1409
1395
if (!(options .flags & REBASE_NO_QUIET ))
@@ -1422,17 +1408,9 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1422
1408
if (gpg_sign )
1423
1409
options .gpg_sign_opt = xstrfmt ("-S%s" , gpg_sign );
1424
1410
1425
- if (exec .nr ) {
1426
- int i ;
1427
-
1411
+ if (options .exec .nr )
1428
1412
imply_merge (& options , "--exec" );
1429
1413
1430
- strbuf_reset (& buf );
1431
- for (i = 0 ; i < exec .nr ; i ++ )
1432
- strbuf_addf (& buf , "exec %s\n" , exec .items [i ].string );
1433
- options .cmd = xstrdup (buf .buf );
1434
- }
1435
-
1436
1414
if (rebase_merges ) {
1437
1415
if (!* rebase_merges )
1438
1416
; /* default mode; do nothing */
@@ -1543,7 +1521,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1543
1521
if (options .empty == EMPTY_UNSPECIFIED ) {
1544
1522
if (options .flags & REBASE_INTERACTIVE_EXPLICIT )
1545
1523
options .empty = EMPTY_ASK ;
1546
- else if (exec .nr > 0 )
1524
+ else if (options . exec .nr > 0 )
1547
1525
options .empty = EMPTY_KEEP ;
1548
1526
else
1549
1527
options .empty = EMPTY_DROP ;
@@ -1831,11 +1809,10 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1831
1809
free (options .head_name );
1832
1810
strvec_clear (& options .git_am_opts );
1833
1811
free (options .gpg_sign_opt );
1834
- free ( options .cmd );
1812
+ string_list_clear ( & options .exec , 0 );
1835
1813
free (options .strategy );
1836
1814
strbuf_release (& options .git_format_patch_opt );
1837
1815
free (squash_onto_name );
1838
- string_list_clear (& exec , 0 );
1839
1816
string_list_clear (& strategy_options , 0 );
1840
1817
return !!ret ;
1841
1818
}
0 commit comments