@@ -121,7 +121,8 @@ struct rebase_options {
121121 struct string_list exec ;
122122 int allow_empty_message ;
123123 int rebase_merges , rebase_cousins ;
124- char * strategy , * strategy_opts ;
124+ char * strategy ;
125+ struct string_list strategy_opts ;
125126 struct strbuf git_format_patch_opt ;
126127 int reschedule_failed_exec ;
127128 int reapply_cherry_picks ;
@@ -150,6 +151,7 @@ struct rebase_options {
150151 .config_rebase_merges = -1, \
151152 .update_refs = -1, \
152153 .config_update_refs = -1, \
154+ .strategy_opts = STRING_LIST_INIT_NODUP,\
153155 }
154156
155157static struct replay_opts get_replay_opts (const struct rebase_options * opts )
@@ -183,8 +185,8 @@ static struct replay_opts get_replay_opts(const struct rebase_options *opts)
183185 replay .default_strategy = NULL ;
184186 }
185187
186- if ( opts -> strategy_opts )
187- parse_strategy_opts (& replay , opts -> strategy_opts );
188+ for ( size_t i = 0 ; i < opts -> strategy_opts . nr ; i ++ )
189+ strvec_push (& replay . xopts , opts -> strategy_opts . items [ i ]. string );
188190
189191 if (opts -> squash_onto ) {
190192 oidcpy (& replay .squash_onto , opts -> squash_onto );
@@ -492,24 +494,6 @@ static int read_basic_state(struct rebase_options *opts)
492494 opts -> gpg_sign_opt = xstrdup (buf .buf );
493495 }
494496
495- if (file_exists (state_dir_path ("strategy" , opts ))) {
496- strbuf_reset (& buf );
497- if (!read_oneliner (& buf , state_dir_path ("strategy" , opts ),
498- READ_ONELINER_WARN_MISSING ))
499- return -1 ;
500- free (opts -> strategy );
501- opts -> strategy = xstrdup (buf .buf );
502- }
503-
504- if (file_exists (state_dir_path ("strategy_opts" , opts ))) {
505- strbuf_reset (& buf );
506- if (!read_oneliner (& buf , state_dir_path ("strategy_opts" , opts ),
507- READ_ONELINER_WARN_MISSING ))
508- return -1 ;
509- free (opts -> strategy_opts );
510- opts -> strategy_opts = xstrdup (buf .buf );
511- }
512-
513497 strbuf_release (& buf );
514498
515499 return 0 ;
@@ -527,12 +511,6 @@ static int rebase_write_basic_state(struct rebase_options *opts)
527511 write_file (state_dir_path ("quiet" , opts ), "%s" , "" );
528512 if (opts -> flags & REBASE_VERBOSE )
529513 write_file (state_dir_path ("verbose" , opts ), "%s" , "" );
530- if (opts -> strategy )
531- write_file (state_dir_path ("strategy" , opts ), "%s" ,
532- opts -> strategy );
533- if (opts -> strategy_opts )
534- write_file (state_dir_path ("strategy_opts" , opts ), "%s" ,
535- opts -> strategy_opts );
536514 if (opts -> allow_rerere_autoupdate > 0 )
537515 write_file (state_dir_path ("allow_rerere_autoupdate" , opts ),
538516 "-%s-rerere-autoupdate" ,
@@ -1089,7 +1067,6 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
10891067 struct object_id branch_base ;
10901068 int ignore_whitespace = 0 ;
10911069 const char * gpg_sign = NULL ;
1092- struct string_list strategy_options = STRING_LIST_INIT_NODUP ;
10931070 struct object_id squash_onto ;
10941071 char * squash_onto_name = NULL ;
10951072 char * keep_base_onto_name = NULL ;
@@ -1197,7 +1174,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
11971174 N_ ("use 'merge-base --fork-point' to refine upstream" )),
11981175 OPT_STRING ('s' , "strategy" , & options .strategy ,
11991176 N_ ("strategy" ), N_ ("use the given merge strategy" )),
1200- OPT_STRING_LIST ('X' , "strategy-option" , & strategy_options ,
1177+ OPT_STRING_LIST ('X' , "strategy-option" , & options . strategy_opts ,
12011178 N_ ("option" ),
12021179 N_ ("pass the argument through to the merge "
12031180 "strategy" )),
@@ -1500,23 +1477,13 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
15001477 } else {
15011478 /* REBASE_MERGE */
15021479 if (ignore_whitespace ) {
1503- string_list_append (& strategy_options ,
1480+ string_list_append (& options . strategy_opts ,
15041481 "ignore-space-change" );
15051482 }
15061483 }
15071484
1508- if (strategy_options .nr ) {
1509- int i ;
1510-
1511- if (!options .strategy )
1512- options .strategy = "ort" ;
1513-
1514- strbuf_reset (& buf );
1515- for (i = 0 ; i < strategy_options .nr ; i ++ )
1516- strbuf_addf (& buf , " --%s" ,
1517- strategy_options .items [i ].string );
1518- options .strategy_opts = xstrdup (buf .buf );
1519- }
1485+ if (options .strategy_opts .nr && !options .strategy )
1486+ options .strategy = "ort" ;
15201487
15211488 if (options .strategy ) {
15221489 options .strategy = xstrdup (options .strategy );
@@ -1898,10 +1865,9 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
18981865 free (options .gpg_sign_opt );
18991866 string_list_clear (& options .exec , 0 );
19001867 free (options .strategy );
1901- free ( options .strategy_opts );
1868+ string_list_clear ( & options .strategy_opts , 0 );
19021869 strbuf_release (& options .git_format_patch_opt );
19031870 free (squash_onto_name );
19041871 free (keep_base_onto_name );
1905- string_list_clear (& strategy_options , 0 );
19061872 return !!ret ;
19071873}
0 commit comments