@@ -69,7 +69,10 @@ static const char * const builtin_merge_usage[] = {
69
69
NULL
70
70
};
71
71
72
- static int show_diffstat = 1 , shortlog_len = -1 , squash ;
72
+ #define MERGE_SHOW_DIFFSTAT 1
73
+ #define MERGE_SHOW_COMPACTSUMMARY 2
74
+
75
+ static int show_diffstat = MERGE_SHOW_DIFFSTAT , shortlog_len = -1 , squash ;
73
76
static int option_commit = -1 ;
74
77
static int option_edit = -1 ;
75
78
static int allow_trivial = 1 , have_message , verify_signatures ;
@@ -243,12 +246,28 @@ static int option_parse_strategy(const struct option *opt UNUSED,
243
246
return 0 ;
244
247
}
245
248
249
+ static int option_parse_compact_summary (const struct option * opt ,
250
+ const char * name UNUSED , int unset )
251
+ {
252
+ int * setting = opt -> value ;
253
+
254
+ if (unset )
255
+ * setting = 0 ;
256
+ else
257
+ * setting = MERGE_SHOW_COMPACTSUMMARY ;
258
+ return 0 ;
259
+ }
260
+
246
261
static struct option builtin_merge_options [] = {
247
262
OPT_SET_INT ('n' , NULL , & show_diffstat ,
248
263
N_ ("do not show a diffstat at the end of the merge" ), 0 ),
249
264
OPT_BOOL (0 , "stat" , & show_diffstat ,
250
265
N_ ("show a diffstat at the end of the merge" )),
251
266
OPT_BOOL (0 , "summary" , & show_diffstat , N_ ("(synonym to --stat)" )),
267
+ OPT_CALLBACK_F (0 , "compact-summary" , & show_diffstat , N_ ("compact-summary" ),
268
+ N_ ("show a compact-summary at the end of the merge" ),
269
+ PARSE_OPT_NOARG ,
270
+ option_parse_compact_summary ),
252
271
{
253
272
.type = OPTION_INTEGER ,
254
273
.long_name = "log" ,
@@ -494,8 +513,19 @@ static void finish(struct commit *head_commit,
494
513
struct diff_options opts ;
495
514
repo_diff_setup (the_repository , & opts );
496
515
init_diffstat_widths (& opts );
497
- opts .output_format |=
498
- DIFF_FORMAT_SUMMARY | DIFF_FORMAT_DIFFSTAT ;
516
+
517
+ switch (show_diffstat ) {
518
+ case MERGE_SHOW_DIFFSTAT : /* 1 */
519
+ opts .output_format |=
520
+ DIFF_FORMAT_SUMMARY | DIFF_FORMAT_DIFFSTAT ;
521
+ break ;
522
+ case MERGE_SHOW_COMPACTSUMMARY : /* 2 */
523
+ opts .output_format |= DIFF_FORMAT_DIFFSTAT ;
524
+ opts .flags .stat_with_summary = 1 ;
525
+ break ;
526
+ default :
527
+ break ;
528
+ }
499
529
opts .detect_rename = DIFF_DETECT_RENAME ;
500
530
diff_setup_done (& opts );
501
531
diff_tree_oid (head , new_head , "" , & opts );
@@ -643,7 +673,35 @@ static int git_merge_config(const char *k, const char *v,
643
673
}
644
674
645
675
if (!strcmp (k , "merge.diffstat" ) || !strcmp (k , "merge.stat" )) {
646
- show_diffstat = git_config_bool (k , v );
676
+ int val = git_parse_maybe_bool_text (v );
677
+ switch (val ) {
678
+ case 0 :
679
+ show_diffstat = 0 ;
680
+ break ;
681
+ case 1 :
682
+ show_diffstat = MERGE_SHOW_DIFFSTAT ;
683
+ break ;
684
+ default :
685
+ if (!strcmp (v , "compact" ))
686
+ show_diffstat = MERGE_SHOW_COMPACTSUMMARY ;
687
+ /*
688
+ * We do not need to have an explicit
689
+ *
690
+ * else if (!strcmp(v, "diffstat"))
691
+ * show_diffstat = MERGE_SHOW_DIFFSTAT;
692
+ *
693
+ * here, because the catch-all uses the
694
+ * diffstat style anyway.
695
+ */
696
+ else
697
+ /*
698
+ * A setting from a future? It is not an
699
+ * error grave enough to fail the command.
700
+ * proceed using the default one.
701
+ */
702
+ show_diffstat = MERGE_SHOW_DIFFSTAT ;
703
+ break ;
704
+ }
647
705
} else if (!strcmp (k , "merge.verifysignatures" )) {
648
706
verify_signatures = git_config_bool (k , v );
649
707
} else if (!strcmp (k , "pull.twohead" )) {
0 commit comments