@@ -355,9 +355,7 @@ void replay_opts_release(struct replay_opts *opts)
355
355
free (opts -> reflog_action );
356
356
free (opts -> default_strategy );
357
357
free (opts -> strategy );
358
- for (size_t i = 0 ; i < opts -> xopts_nr ; i ++ )
359
- free (opts -> xopts [i ]);
360
- free (opts -> xopts );
358
+ strvec_clear (& opts -> xopts );
361
359
strbuf_release (& opts -> current_fixups );
362
360
if (opts -> revs )
363
361
release_revisions (opts -> revs );
@@ -693,8 +691,8 @@ static int do_recursive_merge(struct repository *r,
693
691
next_tree = next ? get_commit_tree (next ) : empty_tree (r );
694
692
base_tree = base ? get_commit_tree (base ) : empty_tree (r );
695
693
696
- for (i = 0 ; i < opts -> xopts_nr ; i ++ )
697
- parse_merge_opt (& o , opts -> xopts [i ]);
694
+ for (i = 0 ; i < opts -> xopts . nr ; i ++ )
695
+ parse_merge_opt (& o , opts -> xopts . v [i ]);
698
696
699
697
if (!opts -> strategy || !strcmp (opts -> strategy , "ort" )) {
700
698
memset (& result , 0 , sizeof (result ));
@@ -2325,7 +2323,7 @@ static int do_pick_commit(struct repository *r,
2325
2323
commit_list_insert (base , & common );
2326
2324
commit_list_insert (next , & remotes );
2327
2325
res |= try_merge_command (r , opts -> strategy ,
2328
- opts -> xopts_nr , ( const char * * ) opts -> xopts ,
2326
+ opts -> xopts . nr , opts -> xopts . v ,
2329
2327
common , oid_to_hex (& head ), remotes );
2330
2328
free_commit_list (common );
2331
2329
free_commit_list (remotes );
@@ -2898,8 +2896,7 @@ static int populate_opts_cb(const char *key, const char *value, void *data)
2898
2896
else if (!strcmp (key , "options.gpg-sign" ))
2899
2897
git_config_string_dup (& opts -> gpg_sign , key , value );
2900
2898
else if (!strcmp (key , "options.strategy-option" )) {
2901
- ALLOC_GROW (opts -> xopts , opts -> xopts_nr + 1 , opts -> xopts_alloc );
2902
- opts -> xopts [opts -> xopts_nr ++ ] = xstrdup (value );
2899
+ strvec_push (& opts -> xopts , value );
2903
2900
} else if (!strcmp (key , "options.allow-rerere-auto" ))
2904
2901
opts -> allow_rerere_auto =
2905
2902
git_config_bool_or_int (key , value , & error_flag ) ?
@@ -2920,23 +2917,23 @@ void parse_strategy_opts(struct replay_opts *opts, char *raw_opts)
2920
2917
{
2921
2918
int i ;
2922
2919
int count ;
2920
+ const char * * argv ;
2923
2921
char * strategy_opts_string = raw_opts ;
2924
2922
2925
2923
if (* strategy_opts_string == ' ' )
2926
2924
strategy_opts_string ++ ;
2927
2925
2928
- count = split_cmdline (strategy_opts_string ,
2929
- (const char * * * )& opts -> xopts );
2926
+ count = split_cmdline (strategy_opts_string , & argv );
2930
2927
if (count < 0 )
2931
2928
die (_ ("could not split '%s': %s" ), strategy_opts_string ,
2932
2929
split_cmdline_strerror (count ));
2933
- opts -> xopts_nr = count ;
2934
- for (i = 0 ; i < opts -> xopts_nr ; i ++ ) {
2935
- const char * arg = opts -> xopts [i ];
2930
+ for (i = 0 ; i < count ; i ++ ) {
2931
+ const char * arg = argv [i ];
2936
2932
2937
2933
skip_prefix (arg , "--" , & arg );
2938
- opts -> xopts [ i ] = xstrdup ( arg );
2934
+ strvec_push ( & opts -> xopts , arg );
2939
2935
}
2936
+ free (argv );
2940
2937
}
2941
2938
2942
2939
static void read_strategy_opts (struct replay_opts * opts , struct strbuf * buf )
@@ -3055,8 +3052,8 @@ static void write_strategy_opts(struct replay_opts *opts)
3055
3052
int i ;
3056
3053
struct strbuf buf = STRBUF_INIT ;
3057
3054
3058
- for (i = 0 ; i < opts -> xopts_nr ; ++ i )
3059
- strbuf_addf (& buf , " --%s" , opts -> xopts [i ]);
3055
+ for (i = 0 ; i < opts -> xopts . nr ; ++ i )
3056
+ strbuf_addf (& buf , " --%s" , opts -> xopts . v [i ]);
3060
3057
3061
3058
write_file (rebase_path_strategy_opts (), "%s\n" , buf .buf );
3062
3059
strbuf_release (& buf );
@@ -3080,7 +3077,7 @@ int write_basic_state(struct replay_opts *opts, const char *head_name,
3080
3077
write_file (rebase_path_verbose (), "%s" , "" );
3081
3078
if (opts -> strategy )
3082
3079
write_file (rebase_path_strategy (), "%s\n" , opts -> strategy );
3083
- if (opts -> xopts_nr > 0 )
3080
+ if (opts -> xopts . nr > 0 )
3084
3081
write_strategy_opts (opts );
3085
3082
3086
3083
if (opts -> allow_rerere_auto == RERERE_AUTOUPDATE )
@@ -3464,13 +3461,10 @@ static int save_opts(struct replay_opts *opts)
3464
3461
if (opts -> gpg_sign )
3465
3462
res |= git_config_set_in_file_gently (opts_file ,
3466
3463
"options.gpg-sign" , opts -> gpg_sign );
3467
- if (opts -> xopts ) {
3468
- int i ;
3469
- for (i = 0 ; i < opts -> xopts_nr ; i ++ )
3470
- res |= git_config_set_multivar_in_file_gently (opts_file ,
3471
- "options.strategy-option" ,
3472
- opts -> xopts [i ], "^$" , 0 );
3473
- }
3464
+ for (size_t i = 0 ; i < opts -> xopts .nr ; i ++ )
3465
+ res |= git_config_set_multivar_in_file_gently (opts_file ,
3466
+ "options.strategy-option" ,
3467
+ opts -> xopts .v [i ], "^$" , 0 );
3474
3468
if (opts -> allow_rerere_auto )
3475
3469
res |= git_config_set_in_file_gently (opts_file ,
3476
3470
"options.allow-rerere-auto" ,
@@ -3880,7 +3874,7 @@ static int do_merge(struct repository *r,
3880
3874
struct commit * head_commit , * merge_commit , * i ;
3881
3875
struct commit_list * bases , * j ;
3882
3876
struct commit_list * to_merge = NULL , * * tail = & to_merge ;
3883
- const char * strategy = !opts -> xopts_nr &&
3877
+ const char * strategy = !opts -> xopts . nr &&
3884
3878
(!opts -> strategy ||
3885
3879
!strcmp (opts -> strategy , "recursive" ) ||
3886
3880
!strcmp (opts -> strategy , "ort" )) ?
@@ -4063,9 +4057,9 @@ static int do_merge(struct repository *r,
4063
4057
strvec_push (& cmd .args , "octopus" );
4064
4058
else {
4065
4059
strvec_push (& cmd .args , strategy );
4066
- for (k = 0 ; k < opts -> xopts_nr ; k ++ )
4060
+ for (k = 0 ; k < opts -> xopts . nr ; k ++ )
4067
4061
strvec_pushf (& cmd .args ,
4068
- "-X%s" , opts -> xopts [k ]);
4062
+ "-X%s" , opts -> xopts . v [k ]);
4069
4063
}
4070
4064
if (!(flags & TODO_EDIT_MERGE_MSG ))
4071
4065
strvec_push (& cmd .args , "--no-edit" );
0 commit comments