summaryrefslogtreecommitdiff
path: root/range-diff.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2018-09-17 20:53:56 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-09-17 20:53:56 (GMT)
commit881c019ea6a0a45f97fb8a1865a88b07263a02ca (patch)
tree1bbb5da82ce92a3ba85114ae641d8fcf62b8d7d6 /range-diff.c
parent688cb1c9891943db1575db38bc0575f75f8b928b (diff)
parent40ce41604daf200cdc85abded0133d40faafc2f8 (diff)
downloadgit-881c019ea6a0a45f97fb8a1865a88b07263a02ca.zip
git-881c019ea6a0a45f97fb8a1865a88b07263a02ca.tar.gz
git-881c019ea6a0a45f97fb8a1865a88b07263a02ca.tar.bz2
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'
Diffstat (limited to 'range-diff.c')
-rw-r--r--range-diff.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/range-diff.c b/range-diff.c
index 3e9b984..60edb2f 100644
--- a/range-diff.c
+++ b/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);