fill in a description in the file before sending it out.
--interdiff=<previous>::
- As a reviewer aid, insert an interdiff into the cover letter showing
+ As a reviewer aid, insert an interdiff into the cover letter,
+ or as commentary of the lone patch of a 1-patch series, showing
the differences between the previous version of the patch series and
the series currently being formatted. `previous` is a single revision
naming the tip of the previous series which shares a common base with
OPT_BOOL(0, "progress", &show_progress,
N_("show progress while generating patches")),
OPT_CALLBACK(0, "interdiff", &idiff_prev, N_("rev"),
- N_("show changes against <rev> in cover letter"),
+ N_("show changes against <rev> in cover letter or single patch"),
parse_opt_object_name),
OPT_END()
};
rev.total = total + start_number - 1;
if (idiff_prev.nr) {
- if (!cover_letter)
- die(_("--interdiff requires --cover-letter"));
+ if (!cover_letter && total != 1)
+ die(_("--interdiff requires --cover-letter or single patch"));
rev.idiff_oid1 = &idiff_prev.oid[idiff_prev.nr - 1];
rev.idiff_oid2 = get_commit_tree_oid(list[0]);
rev.idiff_title = diff_title(&idiff_title, reroll_count,
print_signature(rev.diffopt.file);
total++;
start_number--;
+ /* interdiff in cover-letter; omit from patches */
+ rev.idiff_oid1 = NULL;
}
rev.add_signoff = do_signoff;
#include "sequencer.h"
#include "line-log.h"
#include "help.h"
+#include "interdiff.h"
static struct decoration name_decoration = { "object names" };
static int decoration_loaded;
strbuf_release(&msgbuf);
free(ctx.notes_message);
+
+ if (cmit_fmt_is_mail(ctx.fmt) && opt->idiff_oid1) {
+ struct diff_queue_struct dq;
+
+ memcpy(&dq, &diff_queued_diff, sizeof(diff_queued_diff));
+ DIFF_QUEUE_CLEAR(&diff_queued_diff);
+
+ next_commentary_block(opt, NULL);
+ fprintf_ln(opt->diffopt.file, "%s", opt->idiff_title);
+ show_interdiff(opt, 2);
+
+ memcpy(&diff_queued_diff, &dq, sizeof(diff_queued_diff));
+ }
}
int log_tree_diff_flush(struct rev_info *opt)
EOF
git format-patch --cover-letter --interdiff=boop~2 -1 boop &&
test_i18ngrep "^Interdiff:$" 0000-cover-letter.patch &&
+ test_i18ngrep ! "^Interdiff:$" 0001-fleep.patch &&
sed "1,/^@@ /d; /^-- $/q" <0000-cover-letter.patch >actual &&
test_cmp expect actual
'
test_i18ngrep "^Interdiff ..* v1:$" v2-0000-cover-letter.patch
'
+test_expect_success 'interdiff: solo-patch' '
+ cat >expect <<-\EOF &&
+ +fleep
+
+ EOF
+ git format-patch --interdiff=boop~2 -1 boop &&
+ test_i18ngrep "^Interdiff:$" 0001-fleep.patch &&
+ sed "1,/^ @@ /d; /^$/q" <0001-fleep.patch >actual &&
+ test_cmp expect actual
+'
+
test_done