Skip to content

Commit

Permalink
format-patch: do not let its diff-options affect --range-diff
Browse files Browse the repository at this point in the history
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
a517079 ("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>
  • Loading branch information
gitster committed Nov 30, 2018
1 parent 7068cbc commit d8981c3
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 3 deletions.
5 changes: 5 additions & 0 deletions Documentation/git-format-patch.txt
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,11 @@ feeding the result to `git send-email`.
feature/v2`), or a revision range if the two versions of the series are
disjoint (for example `git format-patch --cover-letter
--range-diff=feature/v1~3..feature/v1 -3 feature/v2`).
+
Note that diff options passed to the command affect how the primary
product of `format-patch` is generated, and they are not passed to
the underlying `range-diff` machinery used to generate the cover-letter
material (this may change in the future).

--creation-factor=<percent>::
Used with `--range-diff`, tweak the heuristic which matches up commits
Expand Down
2 changes: 1 addition & 1 deletion builtin/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -1096,7 +1096,7 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
if (rev->rdiff1) {
fprintf_ln(rev->diffopt.file, "%s", rev->rdiff_title);
show_range_diff(rev->rdiff1, rev->rdiff2,
rev->creation_factor, 1, &rev->diffopt);
rev->creation_factor, 1, NULL);
}
}

Expand Down
2 changes: 1 addition & 1 deletion log-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@ void show_log(struct rev_info *opt)
next_commentary_block(opt, NULL);
fprintf_ln(opt->diffopt.file, "%s", opt->rdiff_title);
show_range_diff(opt->rdiff1, opt->rdiff2,
opt->creation_factor, 1, &opt->diffopt);
opt->creation_factor, 1, NULL);

memcpy(&diff_queued_diff, &dq, sizeof(diff_queued_diff));
}
Expand Down
6 changes: 5 additions & 1 deletion range-diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,11 @@ int show_range_diff(const char *range1, const char *range2,
struct diff_options opts;
struct strbuf indent = STRBUF_INIT;

memcpy(&opts, diffopt, sizeof(opts));
if (diffopt)
memcpy(&opts, diffopt, sizeof(opts));
else
diff_setup(&opts);

if (!opts.output_format)
opts.output_format = DIFF_FORMAT_PATCH;
opts.flags.suppress_diff_headers = 1;
Expand Down
5 changes: 5 additions & 0 deletions range-diff.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@

#define RANGE_DIFF_CREATION_FACTOR_DEFAULT 60

/*
* Compare series of commmits in RANGE1 and RANGE2, and emit to the
* standard output. NULL can be passed to DIFFOPT to use the built-in
* default.
*/
int show_range_diff(const char *range1, const char *range2,
int creation_factor, int dual_color,
struct diff_options *diffopt);
Expand Down

0 comments on commit d8981c3

Please sign in to comment.