Skip to content

Commit 5733b20

Browse files
sorganovgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8c0ba52 commit 5733b20

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

diff-merges.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ static void suppress(struct rev_info *revs)
99
revs->combine_merges = 0;
1010
revs->dense_combined_merges = 0;
1111
revs->combined_all_paths = 0;
12+
revs->combined_imply_patch = 0;
1213
}
1314

1415
static void set_separate(struct rev_info *revs)
@@ -74,19 +75,21 @@ int diff_merges_parse_opts(struct rev_info *revs, const char **argv)
7475
const char *optarg;
7576
const char *arg = argv[0];
7677

77-
if (!strcmp(arg, "-m"))
78+
if (!strcmp(arg, "-m")) {
7879
set_m(revs);
79-
else if (!strcmp(arg, "-c"))
80+
} else if (!strcmp(arg, "-c")) {
8081
set_combined(revs);
81-
else if (!strcmp(arg, "--cc"))
82+
revs->combined_imply_patch = 1;
83+
} else if (!strcmp(arg, "--cc")) {
8284
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")) {
8487
suppress(revs);
85-
else if (!strcmp(arg, "--combined-all-paths"))
88+
} else if (!strcmp(arg, "--combined-all-paths")) {
8689
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))) {
8891
set_diff_merges(revs, optarg);
89-
else
92+
} else
9093
return 0;
9194

9295
revs->explicit_diff_merges = 1;
@@ -126,8 +129,9 @@ void diff_merges_setup_revs(struct rev_info *revs)
126129
revs->first_parent_merges = 0;
127130
if (revs->combined_all_paths && !revs->combine_merges)
128131
die("--combined-all-paths makes no sense without -c or --cc");
129-
if (revs->combine_merges) {
132+
if (revs->combine_merges)
130133
revs->diff = 1;
134+
if (revs->combined_imply_patch) {
131135
/* Turn --cc/-c into -p --cc/-c when -p was not given */
132136
if (!revs->diffopt.output_format)
133137
revs->diffopt.output_format = DIFF_FORMAT_PATCH;

revision.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ struct rev_info {
197197
separate_merges: 1,
198198
combine_merges:1,
199199
combined_all_paths:1,
200+
combined_imply_patch:1,
200201
dense_combined_merges:1,
201202
first_parent_merges:1;
202203

0 commit comments

Comments
 (0)