diff-merges: do not imply -p for new options

Add 'combined_imply_patch' field and set it only for old --cc/-c options, then imply -p if this flag is set instead of implying -p whenever 'combined_merge' flag is set. We don't want new --diff-merge options to imply -p, to make it possible to enable output of diffs for merges independently from non-merge commits. At the same time we want to preserve behavior of old --c/-c/-m options and their interactions with --first-parent, to stay backward-compatible. This patch is first step in this direction: it separates old "--cc/-c imply -p" logic from the rest of the options. Signed-off-by: Sergey Organov <sorganov@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Sergey Organov committed Dec 21, 2020 at 18:19 UTC 5733b20f41ac0fecdacdf34a11acef2d03fac829
2 files changed +13 -8
diff-merges.c
+12 -8
@@ -9,6 +9,7 @@ static void suppress(struct rev_info *revs)
9 revs->combine_merges = 0;
10 revs->dense_combined_merges = 0;
11 revs->combined_all_paths = 0;
12 + revs->combined_imply_patch = 0;
13 }
14
15 static void set_separate(struct rev_info *revs)
@@ -74,19 +75,21 @@ int diff_merges_parse_opts(struct rev_info *revs, const char **argv)
75 const char *optarg;
76 const char *arg = argv[0];
77
77 - if (!strcmp(arg, "-m"))
78 + if (!strcmp(arg, "-m")) {
79 set_m(revs);
79 - else if (!strcmp(arg, "-c"))
80 + } else if (!strcmp(arg, "-c")) {
81 set_combined(revs);
81 - else if (!strcmp(arg, "--cc"))
82 + revs->combined_imply_patch = 1;
83 + } else if (!strcmp(arg, "--cc")) {
84 set_dense_combined(revs);
83 - else if (!strcmp(arg, "--no-diff-merges"))
85 + revs->combined_imply_patch = 1;
86 + } else if (!strcmp(arg, "--no-diff-merges")) {
87 suppress(revs);
85 - else if (!strcmp(arg, "--combined-all-paths"))
88 + } else if (!strcmp(arg, "--combined-all-paths")) {
89 revs->combined_all_paths = 1;
87 - else if ((argcount = parse_long_opt("diff-merges", argv, &optarg)))
90 + } else if ((argcount = parse_long_opt("diff-merges", argv, &optarg))) {
91 set_diff_merges(revs, optarg);
89 - else
92 + } else
93 return 0;
94
95 revs->explicit_diff_merges = 1;
@@ -126,8 +129,9 @@ void diff_merges_setup_revs(struct rev_info *revs)
129 revs->first_parent_merges = 0;
130 if (revs->combined_all_paths && !revs->combine_merges)
131 die("--combined-all-paths makes no sense without -c or --cc");
129 - if (revs->combine_merges) {
132 + if (revs->combine_merges)
133 revs->diff = 1;
134 + if (revs->combined_imply_patch) {
135 /* Turn --cc/-c into -p --cc/-c when -p was not given */
136 if (!revs->diffopt.output_format)
137 revs->diffopt.output_format = DIFF_FORMAT_PATCH;
revision.h
+1
@@ -197,6 +197,7 @@ struct rev_info {
197 separate_merges: 1,
198 combine_merges:1,
199 combined_all_paths:1,
200 + combined_imply_patch:1,
201 dense_combined_merges:1,
202 first_parent_merges:1;
203