diff options
author | Eric Sunshine <sunshine@sunshineco.com> | 2018-07-22 05:57:07 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-07-23 12:50:06 -0700 |
commit | 3b026417eaa1f32f53b85d1b131194ae1cbbf068 (patch) | |
tree | 88021090ad5695a6497243778afdc12d437b9007 /interdiff.c | |
parent | format-patch: teach --interdiff to respect -v/--reroll-count (diff) | |
download | tgif-3b026417eaa1f32f53b85d1b131194ae1cbbf068.tar.xz |
interdiff: teach show_interdiff() to indent interdiff
A future change will allow "git format-patch --interdiff=<prev> -1" to
insert an interdiff into the commentary section of the lone patch of a
1-patch series. However, to prevent the inserted interdiff from
confusing git-am, as well as human readers, it needs to be indented.
Therefore, teach show_interdiff() how to indent.
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'interdiff.c')
-rw-r--r-- | interdiff.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/interdiff.c b/interdiff.c index d0fac10c7c..c81d680a6c 100644 --- a/interdiff.c +++ b/interdiff.c @@ -3,15 +3,26 @@ #include "revision.h" #include "interdiff.h" -void show_interdiff(struct rev_info *rev) +static struct strbuf *idiff_prefix_cb(struct diff_options *opt, void *data) +{ + return data; +} + +void show_interdiff(struct rev_info *rev, int indent) { struct diff_options opts; + struct strbuf prefix = STRBUF_INIT; memcpy(&opts, &rev->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(rev->idiff_oid1, rev->idiff_oid2, "", &opts); diffcore_std(&opts); diff_flush(&opts); + + strbuf_release(&prefix); } |