diff options
author | Sergey Organov <sorganov@gmail.com> | 2020-12-21 18:19:53 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2020-12-21 13:47:32 -0800 |
commit | a6d19ecc6b7715b50b0dced7e3d2923a8797df64 (patch) | |
tree | b6006ef2c22a5e80f455926183584733d4d8357e /diff-merges.c | |
parent | 5733b20f41ac0fecdacdf34a11acef2d03fac829 (diff) | |
download | git-a6d19ecc6b7715b50b0dced7e3d2923a8797df64.tar.gz |
diff-merges: let new options enable diff without -p
New options don't have any visible effect unless -p is either given or
implied, as unlike -c/-cc we don't imply -p with --diff-merges. To fix
this, this patch adds new functionality by letting new options enable
output of diffs for merge commits only.
Add 'merges_need_diff' field and set it whenever diff output for merges is
enabled by any of the new options.
Extend diff output logic accordingly, to output diffs for merges when
'merges_need_diff' is set even when no -p has been provided.
Signed-off-by: Sergey Organov <sorganov@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diff-merges.c')
-rw-r--r-- | diff-merges.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/diff-merges.c b/diff-merges.c index 6d48ac5ab9..ee91ed0db4 100644 --- a/diff-merges.c +++ b/diff-merges.c @@ -10,6 +10,7 @@ static void suppress(struct rev_info *revs) revs->dense_combined_merges = 0; revs->combined_all_paths = 0; revs->combined_imply_patch = 0; + revs->merges_need_diff = 0; } static void set_separate(struct rev_info *revs) @@ -51,9 +52,13 @@ static void set_dense_combined(struct rev_info *revs) static void set_diff_merges(struct rev_info *revs, const char *optarg) { - if (!strcmp(optarg, "off") || !strcmp(optarg, "none")) + if (!strcmp(optarg, "off") || !strcmp(optarg, "none")) { suppress(revs); - else if (!strcmp(optarg, "first-parent")) + /* Return early to leave revs->merges_need_diff unset */ + return; + } + + if (!strcmp(optarg, "first-parent")) set_first_parent(revs); else if (!strcmp(optarg, "separate")) set_separate(revs); @@ -63,6 +68,9 @@ static void set_diff_merges(struct rev_info *revs, const char *optarg) set_dense_combined(revs); else die(_("unknown value for --diff-merges: %s"), optarg); + + /* The flag is cleared by set_xxx() functions, so don't move this up */ + revs->merges_need_diff = 1; } /* @@ -129,10 +137,9 @@ void diff_merges_setup_revs(struct rev_info *revs) revs->first_parent_merges = 0; if (revs->combined_all_paths && !revs->combine_merges) die("--combined-all-paths makes no sense without -c or --cc"); - if (revs->combine_merges) + if (revs->combined_imply_patch) revs->diff = 1; - if (revs->combined_imply_patch) { - /* Turn --cc/-c into -p --cc/-c when -p was not given */ + if (revs->combined_imply_patch || revs->merges_need_diff) { if (!revs->diffopt.output_format) revs->diffopt.output_format = DIFF_FORMAT_PATCH; } |