18
18
#include "quote.h"
19
19
#include "tree.h"
20
20
#include "config.h"
21
+ #include "strvec.h"
21
22
22
23
static int line_termination = '\n' ;
23
24
@@ -414,6 +415,7 @@ struct merge_tree_options {
414
415
int show_messages ;
415
416
int name_only ;
416
417
int use_stdin ;
418
+ struct merge_options merge_options ;
417
419
};
418
420
419
421
static int real_merge (struct merge_tree_options * o ,
@@ -423,7 +425,7 @@ static int real_merge(struct merge_tree_options *o,
423
425
{
424
426
struct commit * parent1 , * parent2 ;
425
427
struct commit_list * merge_bases = NULL ;
426
- struct merge_options opt ;
428
+ struct merge_options opt = o -> merge_options ;
427
429
struct merge_result result = { 0 };
428
430
int show_messages = o -> show_messages ;
429
431
@@ -437,8 +439,6 @@ static int real_merge(struct merge_tree_options *o,
437
439
help_unknown_ref (branch2 , "merge-tree" ,
438
440
_ ("not something we can merge" ));
439
441
440
- init_merge_options (& opt , the_repository );
441
-
442
442
opt .show_rename_progress = 0 ;
443
443
444
444
opt .branch1 = branch1 ;
@@ -513,6 +513,7 @@ static int real_merge(struct merge_tree_options *o,
513
513
int cmd_merge_tree (int argc , const char * * argv , const char * prefix )
514
514
{
515
515
struct merge_tree_options o = { .show_messages = -1 };
516
+ struct strvec xopts = STRVEC_INIT ;
516
517
int expected_remaining_argc ;
517
518
int original_argc ;
518
519
const char * merge_base = NULL ;
@@ -548,14 +549,25 @@ int cmd_merge_tree(int argc, const char **argv, const char *prefix)
548
549
& merge_base ,
549
550
N_ ("commit" ),
550
551
N_ ("specify a merge-base for the merge" )),
552
+ OPT_STRVEC ('X' , "strategy-option" , & xopts , N_ ("option=value" ),
553
+ N_ ("option for selected merge strategy" )),
551
554
OPT_END ()
552
555
};
553
556
557
+ /* Init merge options */
558
+ init_merge_options (& o .merge_options , the_repository );
559
+
554
560
/* Parse arguments */
555
561
original_argc = argc - 1 ; /* ignoring argv[0] */
556
562
argc = parse_options (argc , argv , prefix , mt_options ,
557
563
merge_tree_usage , PARSE_OPT_STOP_AT_NON_OPTION );
558
564
565
+ if (xopts .nr && o .mode == MODE_TRIVIAL )
566
+ die (_ ("--trivial-merge is incompatible with all other options" ));
567
+ for (int x = 0 ; x < xopts .nr ; x ++ )
568
+ if (parse_merge_opt (& o .merge_options , xopts .v [x ]))
569
+ die (_ ("unknown strategy option: -X%s" ), xopts .v [x ]);
570
+
559
571
/* Handle --stdin */
560
572
if (o .use_stdin ) {
561
573
struct strbuf buf = STRBUF_INIT ;
0 commit comments