summaryrefslogtreecommitdiff
path: root/log-tree.c
diff options
context:
space:
mode:
authorMartin Ågren <martin.agren@gmail.com>2018-12-03 21:21:31 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-12-04 01:36:14 (GMT)
commitac0edf1f46fcf9b9f6f1156e555bdf740cd56c5f (patch)
treea193ede10eb5daf1045f2bb05a49cfb21d163a10 /log-tree.c
parentd8981c3f885ceaddfec0e545b0f995b96e5ec58f (diff)
downloadgit-ac0edf1f46fcf9b9f6f1156e555bdf740cd56c5f.zip
git-ac0edf1f46fcf9b9f6f1156e555bdf740cd56c5f.tar.gz
git-ac0edf1f46fcf9b9f6f1156e555bdf740cd56c5f.tar.bz2
range-diff: always pass at least minimal diff options
Commit d8981c3f88 ("format-patch: do not let its diff-options affect --range-diff", 2018-11-30) taught `show_range_diff()` to accept a NULL-pointer as an indication that it should use its own "reasonable default". That fixed a regression from a5170794 ("Merge branch 'ab/range-diff-no-patch'", 2018-11-18), but unfortunately it introduced a regression of its own. In particular, it means we forget the `file` member of the diff options, so rather than placing a range-diff in the cover-letter, we write it to stdout. In order to fix this, rewrite the two callers adjusted by d8981c3f88 to instead create a "dummy" set of diff options where they only fill in the fields we absolutely require, such as output file and color. Modify and extend the existing tests to try and verify that the right contents end up in the right place. Don't revert `show_range_diff()`, i.e., let it keep accepting NULL. Rather than removing what is dead code and figuring out it isn't actually dead and we've broken 2.20, just leave it for now. [es: retain diff coloring when going to stdout] Signed-off-by: Martin Ågren <martin.agren@gmail.com> Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'log-tree.c')
-rw-r--r--log-tree.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/log-tree.c b/log-tree.c
index b243779..10680c1 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -755,14 +755,23 @@ void show_log(struct rev_info *opt)
if (cmit_fmt_is_mail(ctx.fmt) && opt->rdiff1) {
struct diff_queue_struct dq;
+ struct diff_options opts;
memcpy(&dq, &diff_queued_diff, sizeof(diff_queued_diff));
DIFF_QUEUE_CLEAR(&diff_queued_diff);
next_commentary_block(opt, NULL);
fprintf_ln(opt->diffopt.file, "%s", opt->rdiff_title);
+ /*
+ * Pass minimum required diff-options to range-diff; others
+ * can be added later if deemed desirable.
+ */
+ diff_setup(&opts);
+ opts.file = opt->diffopt.file;
+ opts.use_color = opt->diffopt.use_color;
+ diff_setup_done(&opts);
show_range_diff(opt->rdiff1, opt->rdiff2,
- opt->creation_factor, 1, NULL);
+ opt->creation_factor, 1, &opts);
memcpy(&diff_queued_diff, &dq, sizeof(diff_queued_diff));
}