diff-merges: revise revs->diff flag handling

Do not set revs->diff when we encounter an option that needs it, as
it'd be impossible to undo later. Besides, some other options than
what we handle here set this flag as well, and we'd interfere with
them trying to clear this flag later.

Rather set revs->diff, if finally needed, in diff_merges_setup_revs().

As an additional bonus, this also makes our code shorter.

Signed-off-by: Sergey Organov <sorganov@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Sergey Organov 2020-12-21 18:19:42 +03:00 коммит произвёл Junio C Hamano
Родитель 0c627f5d3c
Коммит e121b4b822
1 изменённых файлов: 1 добавлений и 3 удалений

Просмотреть файл

@ -41,16 +41,13 @@ int diff_merges_parse_opts(struct rev_info *revs, const char **argv)
revs->ignore_merges = 0;
revs->match_missing = 1;
} else if (!strcmp(arg, "-c")) {
revs->diff = 1;
revs->dense_combined_merges = 0;
revs->combine_merges = 1;
} else if (!strcmp(arg, "--cc")) {
revs->diff = 1;
set_dense_combined(revs);
} else if (!strcmp(arg, "--no-diff-merges")) {
suppress(revs);
} else if (!strcmp(arg, "--combined-all-paths")) {
revs->diff = 1;
revs->combined_all_paths = 1;
} else if ((argcount = parse_long_opt("diff-merges", argv, &optarg))) {
if (!strcmp(optarg, "off")) {
@ -103,6 +100,7 @@ void diff_merges_setup_revs(struct rev_info *revs)
if (revs->combined_all_paths && !revs->combine_merges)
die("--combined-all-paths makes no sense without -c or --cc");
if (revs->combine_merges) {
revs->diff = 1;
/* Turn --cc/-c into -p --cc/-c when -p was not given */
if (!revs->diffopt.output_format)
revs->diffopt.output_format = DIFF_FORMAT_PATCH;