format-patch: do not let its diff-options affect --range-diff

Stop leaking how the primary output of format-patch is customized to the range-diff machinery and instead let the latter use its own "reasonable default", in order to correct the breakage introduced by a5170794 ("Merge branch 'ab/range-diff-no-patch'", 2018-11-18) on the 'master' front. "git format-patch --range-diff..." without any weird diff option started to include the "range-diff --stat" output, which is rather useless right now, that made the whole thing unusable and this is probably the least disruptive way to whip the codebase into a shippable shape. We may want to later make the range-diff driven by format-patch more configurable, but that would have to wait until we have a good design. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Nov 30, 2018 at 13:27 UTC d8981c3f885ceaddfec0e545b0f995b96e5ec58f
5 files changed +17 -3
Documentation/git-format-patch.txt
+5
@@ -250,6 +250,11 @@ feeding the result to `git send-email`.
250 feature/v2`), or a revision range if the two versions of the series are
251 disjoint (for example `git format-patch --cover-letter
252 --range-diff=feature/v1~3..feature/v1 -3 feature/v2`).
253 ++
254 +Note that diff options passed to the command affect how the primary
255 +product of `format-patch` is generated, and they are not passed to
256 +the underlying `range-diff` machinery used to generate the cover-letter
257 +material (this may change in the future).
258
259 --creation-factor=<percent>::
260 Used with `--range-diff`, tweak the heuristic which matches up commits
builtin/log.c
+1 -1
@@ -1096,7 +1096,7 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
1096 if (rev->rdiff1) {
1097 fprintf_ln(rev->diffopt.file, "%s", rev->rdiff_title);
1098 show_range_diff(rev->rdiff1, rev->rdiff2,
1099 - rev->creation_factor, 1, &rev->diffopt);
1099 + rev->creation_factor, 1, NULL);
1100 }
1101 }
1102
log-tree.c
+1 -1
@@ -762,7 +762,7 @@ void show_log(struct rev_info *opt)
762 next_commentary_block(opt, NULL);
763 fprintf_ln(opt->diffopt.file, "%s", opt->rdiff_title);
764 show_range_diff(opt->rdiff1, opt->rdiff2,
765 - opt->creation_factor, 1, &opt->diffopt);
765 + opt->creation_factor, 1, NULL);
766
767 memcpy(&diff_queued_diff, &dq, sizeof(diff_queued_diff));
768 }
range-diff.c
+5 -1
@@ -460,7 +460,11 @@ int show_range_diff(const char *range1, const char *range2,
460 struct diff_options opts;
461 struct strbuf indent = STRBUF_INIT;
462
463 - memcpy(&opts, diffopt, sizeof(opts));
463 + if (diffopt)
464 + memcpy(&opts, diffopt, sizeof(opts));
465 + else
466 + diff_setup(&opts);
467 +
468 if (!opts.output_format)
469 opts.output_format = DIFF_FORMAT_PATCH;
470 opts.flags.suppress_diff_headers = 1;
range-diff.h
+5
@@ -5,6 +5,11 @@
5
6 #define RANGE_DIFF_CREATION_FACTOR_DEFAULT 60
7
8 +/*
9 + * Compare series of commmits in RANGE1 and RANGE2, and emit to the
10 + * standard output. NULL can be passed to DIFFOPT to use the built-in
11 + * default.
12 + */
13 int show_range_diff(const char *range1, const char *range2,
14 int creation_factor, int dual_color,
15 struct diff_options *diffopt);