summaryrefslogtreecommitdiff
path: root/diff-lib.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2020-09-22 12:36:28 -0700
committerJunio C Hamano <gitster@pobox.com>2020-09-22 12:36:28 -0700
commit634e0084fac75cf85449a813da14968c9663a094 (patch)
tree4954184348dd7032043726df7a2e622e97b52d46 /diff-lib.c
parentbcb68bff80eab46f9d5f367555da803e61d3d7c8 (diff)
parent07a7f8debfa43bd28537f475925776a92c30a678 (diff)
downloadgit-634e0084fac75cf85449a813da14968c9663a094.tar.gz
Merge branch 'es/format-patch-interdiff-cleanup'
"format-patch --range-diff=<prev> <origin>..HEAD" has been taught not to ignore <origin> when <prev> is a single version. * es/format-patch-interdiff-cleanup: format-patch: use 'origin' as start of current-series-range when known diff-lib: tighten show_interdiff()'s interface diff: move show_interdiff() from its own file to diff-lib
Diffstat (limited to 'diff-lib.c')
-rw-r--r--diff-lib.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/diff-lib.c b/diff-lib.c
index 5d5d3dafab..346fdcf0b0 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -565,3 +565,28 @@ int index_differs_from(struct repository *r,
object_array_clear(&rev.pending);
return (rev.diffopt.flags.has_changes != 0);
}
+
+static struct strbuf *idiff_prefix_cb(struct diff_options *opt, void *data)
+{
+ return data;
+}
+
+void show_interdiff(const struct object_id *oid1, const struct object_id *oid2,
+ int indent, struct diff_options *diffopt)
+{
+ struct diff_options opts;
+ struct strbuf prefix = STRBUF_INIT;
+
+ memcpy(&opts, diffopt, sizeof(opts));
+ opts.output_format = DIFF_FORMAT_PATCH;
+ opts.output_prefix = idiff_prefix_cb;
+ strbuf_addchars(&prefix, ' ', indent);
+ opts.output_prefix_data = &prefix;
+ diff_setup_done(&opts);
+
+ diff_tree_oid(oid1, oid2, "", &opts);
+ diffcore_std(&opts);
+ diff_flush(&opts);
+
+ strbuf_release(&prefix);
+}