Merge branch 'es/format-patch-rangediff'
"git format-patch" learned a new "--range-diff" option to explain the difference between this version and the previous attempt in the cover letter (or after the tree-dashes as a comment). * es/format-patch-rangediff: format-patch: allow --range-diff to apply to a lone-patch format-patch: add --creation-factor tweak for --range-diff format-patch: teach --range-diff to respect -v/--reroll-count format-patch: extend --range-diff to accept revision range format-patch: add --range-diff option to embed diff in cover letter range-diff: relieve callers of low-level configuration burden range-diff: publish default creation factor range-diff: respect diff_option.file rather than assuming 'stdout'
This commit is contained in:
26
range-diff.c
26
range-diff.c
@ -343,7 +343,7 @@ static void output_pair_header(struct diff_options *diffopt,
|
||||
}
|
||||
strbuf_addf(buf, "%s\n", color_reset);
|
||||
|
||||
fwrite(buf->buf, buf->len, 1, stdout);
|
||||
fwrite(buf->buf, buf->len, 1, diffopt->file);
|
||||
}
|
||||
|
||||
static struct userdiff_driver no_func_name = {
|
||||
@ -429,8 +429,14 @@ static void output(struct string_list *a, struct string_list *b,
|
||||
strbuf_release(&dashes);
|
||||
}
|
||||
|
||||
static struct strbuf *output_prefix_cb(struct diff_options *opt, void *data)
|
||||
{
|
||||
return data;
|
||||
}
|
||||
|
||||
int show_range_diff(const char *range1, const char *range2,
|
||||
int creation_factor, struct diff_options *diffopt)
|
||||
int creation_factor, int dual_color,
|
||||
struct diff_options *diffopt)
|
||||
{
|
||||
int res = 0;
|
||||
|
||||
@ -443,9 +449,23 @@ int show_range_diff(const char *range1, const char *range2,
|
||||
res = error(_("could not parse log for '%s'"), range2);
|
||||
|
||||
if (!res) {
|
||||
struct diff_options opts;
|
||||
struct strbuf indent = STRBUF_INIT;
|
||||
|
||||
memcpy(&opts, diffopt, sizeof(opts));
|
||||
opts.output_format = DIFF_FORMAT_PATCH;
|
||||
opts.flags.suppress_diff_headers = 1;
|
||||
opts.flags.dual_color_diffed_diffs = dual_color;
|
||||
opts.output_prefix = output_prefix_cb;
|
||||
strbuf_addstr(&indent, " ");
|
||||
opts.output_prefix_data = &indent;
|
||||
diff_setup_done(&opts);
|
||||
|
||||
find_exact_matches(&branch1, &branch2);
|
||||
get_correspondences(&branch1, &branch2, creation_factor);
|
||||
output(&branch1, &branch2, diffopt);
|
||||
output(&branch1, &branch2, &opts);
|
||||
|
||||
strbuf_release(&indent);
|
||||
}
|
||||
|
||||
string_list_clear(&branch1, 1);
|
||||
|
||||
Reference in New Issue
Block a user