@@ -4615,8 +4615,6 @@ static void run_checkdiff(struct diff_filepair *p, struct diff_options *o)
4615
4615
builtin_checkdiff (name , other , attr_path , p -> one , p -> two , o );
4616
4616
}
4617
4617
4618
- static void prep_parse_options (struct diff_options * options );
4619
-
4620
4618
void repo_diff_setup (struct repository * r , struct diff_options * options )
4621
4619
{
4622
4620
memcpy (options , & default_diff_options , sizeof (* options ));
@@ -4662,8 +4660,6 @@ void repo_diff_setup(struct repository *r, struct diff_options *options)
4662
4660
4663
4661
options -> color_moved = diff_color_moved_default ;
4664
4662
options -> color_moved_ws_handling = diff_color_moved_ws_default ;
4665
-
4666
- prep_parse_options (options );
4667
4663
}
4668
4664
4669
4665
static const char diff_status_letters [] = {
@@ -4821,8 +4817,6 @@ void diff_setup_done(struct diff_options *options)
4821
4817
options -> filter = ~filter_bit [DIFF_STATUS_FILTER_AON ];
4822
4818
options -> filter &= ~options -> filter_not ;
4823
4819
}
4824
-
4825
- FREE_AND_NULL (options -> parseopts );
4826
4820
}
4827
4821
4828
4822
int parse_long_opt (const char * opt , const char * * argv ,
@@ -5419,7 +5413,8 @@ static int diff_opt_rotate_to(const struct option *opt, const char *arg, int uns
5419
5413
return 0 ;
5420
5414
}
5421
5415
5422
- static void prep_parse_options (struct diff_options * options )
5416
+ struct option * add_diff_options (const struct option * opts ,
5417
+ struct diff_options * options )
5423
5418
{
5424
5419
struct option parseopts [] = {
5425
5420
OPT_GROUP (N_ ("Diff output format options" )),
@@ -5689,22 +5684,25 @@ static void prep_parse_options(struct diff_options *options)
5689
5684
OPT_END ()
5690
5685
};
5691
5686
5692
- ALLOC_ARRAY (options -> parseopts , ARRAY_SIZE (parseopts ));
5693
- memcpy (options -> parseopts , parseopts , sizeof (parseopts ));
5687
+ return parse_options_concat (opts , parseopts );
5694
5688
}
5695
5689
5696
5690
int diff_opt_parse (struct diff_options * options ,
5697
5691
const char * * av , int ac , const char * prefix )
5698
5692
{
5693
+ struct option no_options [] = { OPT_END () };
5694
+ struct option * parseopts = add_diff_options (no_options , options );
5695
+
5699
5696
if (!prefix )
5700
5697
prefix = "" ;
5701
5698
5702
- ac = parse_options (ac , av , prefix , options -> parseopts , NULL ,
5699
+ ac = parse_options (ac , av , prefix , parseopts , NULL ,
5703
5700
PARSE_OPT_KEEP_DASHDASH |
5704
5701
PARSE_OPT_KEEP_UNKNOWN_OPT |
5705
5702
PARSE_OPT_NO_INTERNAL_HELP |
5706
5703
PARSE_OPT_ONE_SHOT |
5707
5704
PARSE_OPT_STOP_AT_NON_OPTION );
5705
+ free (parseopts );
5708
5706
5709
5707
return ac ;
5710
5708
}
@@ -6513,7 +6511,6 @@ void diff_free(struct diff_options *options)
6513
6511
diff_free_file (options );
6514
6512
diff_free_ignore_regex (options );
6515
6513
clear_pathspec (& options -> pathspec );
6516
- FREE_AND_NULL (options -> parseopts );
6517
6514
}
6518
6515
6519
6516
void diff_flush (struct diff_options * options )
0 commit comments