@@ -56,6 +56,7 @@ static size_t use_strategies_nr, use_strategies_alloc;
56
56
static const char * * xopts ;
57
57
static size_t xopts_nr , xopts_alloc ;
58
58
static const char * branch ;
59
+ static char * branch_mergeoptions ;
59
60
static int option_renormalize ;
60
61
static int verbosity ;
61
62
static int allow_rerere_auto ;
@@ -503,26 +504,34 @@ static void merge_name(const char *remote, struct strbuf *msg)
503
504
strbuf_release (& bname );
504
505
}
505
506
507
+ static void parse_branch_merge_options (char * bmo )
508
+ {
509
+ const char * * argv ;
510
+ int argc ;
511
+
512
+ if (!bmo )
513
+ return ;
514
+ argc = split_cmdline (bmo , & argv );
515
+ if (argc < 0 )
516
+ die (_ ("Bad branch.%s.mergeoptions string: %s" ), branch ,
517
+ split_cmdline_strerror (argc ));
518
+ argv = xrealloc (argv , sizeof (* argv ) * (argc + 2 ));
519
+ memmove (argv + 1 , argv , sizeof (* argv ) * (argc + 1 ));
520
+ argc ++ ;
521
+ argv [0 ] = "branch.*.mergeoptions" ;
522
+ parse_options (argc , argv , NULL , builtin_merge_options ,
523
+ builtin_merge_usage , 0 );
524
+ free (argv );
525
+ }
526
+
506
527
static int git_merge_config (const char * k , const char * v , void * cb )
507
528
{
508
529
if (branch && !prefixcmp (k , "branch." ) &&
509
530
!prefixcmp (k + 7 , branch ) &&
510
531
!strcmp (k + 7 + strlen (branch ), ".mergeoptions" )) {
511
- const char * * argv ;
512
- int argc ;
513
- char * buf ;
514
-
515
- buf = xstrdup (v );
516
- argc = split_cmdline (buf , & argv );
517
- if (argc < 0 )
518
- die (_ ("Bad branch.%s.mergeoptions string: %s" ), branch ,
519
- split_cmdline_strerror (argc ));
520
- argv = xrealloc (argv , sizeof (* argv ) * (argc + 2 ));
521
- memmove (argv + 1 , argv , sizeof (* argv ) * (argc + 1 ));
522
- argc ++ ;
523
- parse_options (argc , argv , NULL , builtin_merge_options ,
524
- builtin_merge_usage , 0 );
525
- free (buf );
532
+ free (branch_mergeoptions );
533
+ branch_mergeoptions = xstrdup (v );
534
+ return 0 ;
526
535
}
527
536
528
537
if (!strcmp (k , "merge.diffstat" ) || !strcmp (k , "merge.stat" ))
@@ -1010,6 +1019,8 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
1010
1019
if (diff_use_color_default == -1 )
1011
1020
diff_use_color_default = git_use_color_default ;
1012
1021
1022
+ if (branch_mergeoptions )
1023
+ parse_branch_merge_options (branch_mergeoptions );
1013
1024
argc = parse_options (argc , argv , prefix , builtin_merge_options ,
1014
1025
builtin_merge_usage , 0 );
1015
1026
0 commit comments