mirror of
https://github.com/git/git
synced 2024-06-30 22:54:27 +00:00
Merge branch 'jc/format-patch-with-range-diff'
The inter/range-diff output has been moved to the end of the patch when format-patch adds it to a single patch, instead of writing it before the patch text, to be consistent with what is done for a cover letter for a multi-patch series. * jc/format-patch-with-range-diff: format-patch: move range/inter diff at the end of a single patch output show_log: factor out interdiff/range-diff generation
This commit is contained in:
commit
4d8ae4d3ca
89
log-tree.c
89
log-tree.c
|
@ -673,6 +673,51 @@ static void next_commentary_block(struct rev_info *opt, struct strbuf *sb)
|
|||
opt->shown_dashes = 1;
|
||||
}
|
||||
|
||||
static void show_diff_of_diff(struct rev_info *opt)
|
||||
{
|
||||
if (!cmit_fmt_is_mail(opt->commit_format))
|
||||
return;
|
||||
|
||||
if (opt->idiff_oid1) {
|
||||
struct diff_queue_struct dq;
|
||||
|
||||
memcpy(&dq, &diff_queued_diff, sizeof(diff_queued_diff));
|
||||
DIFF_QUEUE_CLEAR(&diff_queued_diff);
|
||||
|
||||
fprintf_ln(opt->diffopt.file, "\n%s", opt->idiff_title);
|
||||
show_interdiff(opt->idiff_oid1, opt->idiff_oid2, 2,
|
||||
&opt->diffopt);
|
||||
|
||||
memcpy(&diff_queued_diff, &dq, sizeof(diff_queued_diff));
|
||||
}
|
||||
|
||||
if (opt->rdiff1) {
|
||||
struct diff_queue_struct dq;
|
||||
struct diff_options opts;
|
||||
struct range_diff_options range_diff_opts = {
|
||||
.creation_factor = opt->creation_factor,
|
||||
.dual_color = 1,
|
||||
.diffopt = &opts
|
||||
};
|
||||
|
||||
memcpy(&dq, &diff_queued_diff, sizeof(diff_queued_diff));
|
||||
DIFF_QUEUE_CLEAR(&diff_queued_diff);
|
||||
|
||||
fprintf_ln(opt->diffopt.file, "\n%s", opt->rdiff_title);
|
||||
/*
|
||||
* Pass minimum required diff-options to range-diff; others
|
||||
* can be added later if deemed desirable.
|
||||
*/
|
||||
repo_diff_setup(the_repository, &opts);
|
||||
opts.file = opt->diffopt.file;
|
||||
opts.use_color = opt->diffopt.use_color;
|
||||
diff_setup_done(&opts);
|
||||
show_range_diff(opt->rdiff1, opt->rdiff2, &range_diff_opts);
|
||||
|
||||
memcpy(&diff_queued_diff, &dq, sizeof(diff_queued_diff));
|
||||
}
|
||||
}
|
||||
|
||||
void show_log(struct rev_info *opt)
|
||||
{
|
||||
struct strbuf msgbuf = STRBUF_INIT;
|
||||
|
@ -856,47 +901,6 @@ void show_log(struct rev_info *opt)
|
|||
strbuf_release(&msgbuf);
|
||||
free(ctx.notes_message);
|
||||
free(ctx.after_subject);
|
||||
|
||||
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->idiff_oid1, opt->idiff_oid2, 2,
|
||||
&opt->diffopt);
|
||||
|
||||
memcpy(&diff_queued_diff, &dq, sizeof(diff_queued_diff));
|
||||
}
|
||||
|
||||
if (cmit_fmt_is_mail(ctx.fmt) && opt->rdiff1) {
|
||||
struct diff_queue_struct dq;
|
||||
struct diff_options opts;
|
||||
struct range_diff_options range_diff_opts = {
|
||||
.creation_factor = opt->creation_factor,
|
||||
.dual_color = 1,
|
||||
.diffopt = &opts
|
||||
};
|
||||
|
||||
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->rdiff_title);
|
||||
/*
|
||||
* Pass minimum required diff-options to range-diff; others
|
||||
* can be added later if deemed desirable.
|
||||
*/
|
||||
repo_diff_setup(the_repository, &opts);
|
||||
opts.file = opt->diffopt.file;
|
||||
opts.use_color = opt->diffopt.use_color;
|
||||
diff_setup_done(&opts);
|
||||
show_range_diff(opt->rdiff1, opt->rdiff2, &range_diff_opts);
|
||||
|
||||
memcpy(&diff_queued_diff, &dq, sizeof(diff_queued_diff));
|
||||
}
|
||||
}
|
||||
|
||||
int log_tree_diff_flush(struct rev_info *opt)
|
||||
|
@ -1165,9 +1169,12 @@ int log_tree_commit(struct rev_info *opt, struct commit *commit)
|
|||
}
|
||||
if (opt->track_linear && !opt->linear && opt->reverse_output_stage)
|
||||
fprintf(opt->diffopt.file, "\n%s\n", opt->break_bar);
|
||||
if (shown)
|
||||
show_diff_of_diff(opt);
|
||||
opt->loginfo = NULL;
|
||||
maybe_flush_or_die(opt->diffopt.file, "stdout");
|
||||
opt->diffopt.no_free = no_free;
|
||||
|
||||
diff_free(&opt->diffopt);
|
||||
return shown;
|
||||
}
|
||||
|
|
|
@ -2482,13 +2482,37 @@ test_expect_success 'interdiff: reroll-count with a integer' '
|
|||
'
|
||||
|
||||
test_expect_success 'interdiff: solo-patch' '
|
||||
cat >expect <<-\EOF &&
|
||||
+fleep
|
||||
|
||||
EOF
|
||||
git format-patch --interdiff=boop~2 -1 boop &&
|
||||
test_grep "^Interdiff:$" 0001-fleep.patch &&
|
||||
sed "1,/^ @@ /d; /^$/q" 0001-fleep.patch >actual &&
|
||||
|
||||
# remove up to the last "patch" output line,
|
||||
# and remove everything below the signature mark.
|
||||
sed -e "1,/^+fleep\$/d" -e "/^-- /,\$d" 0001-fleep.patch >actual &&
|
||||
|
||||
# fabricate Interdiff output.
|
||||
git diff boop~2 boop >inter &&
|
||||
{
|
||||
echo &&
|
||||
echo "Interdiff:" &&
|
||||
sed -e "s/^/ /" inter
|
||||
} >expect &&
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success 'range-diff: solo-patch' '
|
||||
git format-patch --creation-factor=999 \
|
||||
--range-diff=boop~2..boop~1 -1 boop &&
|
||||
|
||||
# remove up to the last "patch" output line,
|
||||
# and remove everything below the signature mark.
|
||||
sed -e "1,/^+fleep\$/d" -e "/^-- /,\$d" 0001-fleep.patch >actual &&
|
||||
|
||||
# fabricate range-diff output.
|
||||
{
|
||||
echo &&
|
||||
echo "Range-diff:" &&
|
||||
git range-diff --creation-factor=999 \
|
||||
boop~2..boop~1 boop~1..boop
|
||||
} >expect &&
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user