mirror of
https://github.com/git/git
synced 2024-11-04 16:17:49 +00:00
format-patch: move range/inter diff at the end of a single patch output
When running "format-patch" on a multiple patch series, the output coming from "--interdiff" and "--range-diff" options is inserted after the "shortlog" list of commits and the overall diffstat. The idea is that shortlog/diffstat are shorter and with denser information content, which gives a better overview before the readers dive into more details of range/inter diff. When working on a single patch, however, we stuff the inter/range diff output before the actual patch, next to the diffstat. This pushes down the patch text way down with inter/range diff output, distracting readers. Move the inter/range diff output to the very end of the output, after all the patch text is shown. As the inter/range diff is no longer part of the commentary block (i.e., what comes after the log message and "---", but before the patch text), stop producing "---" in the function that generates them. But to separate it out visually (note: this is not needed to help tools like "git apply" that pay attention to the hunk headers to figure out the length of the hunks), add an extra blank line between the end of the patch text and the inter/range diff. Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
84ed505515
commit
2fa04cebfb
2 changed files with 35 additions and 12 deletions
11
log-tree.c
11
log-tree.c
|
@ -684,8 +684,7 @@ static void show_diff_of_diff(struct rev_info *opt)
|
||||||
memcpy(&dq, &diff_queued_diff, sizeof(diff_queued_diff));
|
memcpy(&dq, &diff_queued_diff, sizeof(diff_queued_diff));
|
||||||
DIFF_QUEUE_CLEAR(&diff_queued_diff);
|
DIFF_QUEUE_CLEAR(&diff_queued_diff);
|
||||||
|
|
||||||
next_commentary_block(opt, NULL);
|
fprintf_ln(opt->diffopt.file, "\n%s", opt->idiff_title);
|
||||||
fprintf_ln(opt->diffopt.file, "%s", opt->idiff_title);
|
|
||||||
show_interdiff(opt->idiff_oid1, opt->idiff_oid2, 2,
|
show_interdiff(opt->idiff_oid1, opt->idiff_oid2, 2,
|
||||||
&opt->diffopt);
|
&opt->diffopt);
|
||||||
|
|
||||||
|
@ -704,8 +703,7 @@ static void show_diff_of_diff(struct rev_info *opt)
|
||||||
memcpy(&dq, &diff_queued_diff, sizeof(diff_queued_diff));
|
memcpy(&dq, &diff_queued_diff, sizeof(diff_queued_diff));
|
||||||
DIFF_QUEUE_CLEAR(&diff_queued_diff);
|
DIFF_QUEUE_CLEAR(&diff_queued_diff);
|
||||||
|
|
||||||
next_commentary_block(opt, NULL);
|
fprintf_ln(opt->diffopt.file, "\n%s", opt->rdiff_title);
|
||||||
fprintf_ln(opt->diffopt.file, "%s", opt->rdiff_title);
|
|
||||||
/*
|
/*
|
||||||
* Pass minimum required diff-options to range-diff; others
|
* Pass minimum required diff-options to range-diff; others
|
||||||
* can be added later if deemed desirable.
|
* can be added later if deemed desirable.
|
||||||
|
@ -903,8 +901,6 @@ void show_log(struct rev_info *opt)
|
||||||
strbuf_release(&msgbuf);
|
strbuf_release(&msgbuf);
|
||||||
free(ctx.notes_message);
|
free(ctx.notes_message);
|
||||||
free(ctx.after_subject);
|
free(ctx.after_subject);
|
||||||
|
|
||||||
show_diff_of_diff(opt);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int log_tree_diff_flush(struct rev_info *opt)
|
int log_tree_diff_flush(struct rev_info *opt)
|
||||||
|
@ -1173,9 +1169,12 @@ int log_tree_commit(struct rev_info *opt, struct commit *commit)
|
||||||
}
|
}
|
||||||
if (opt->track_linear && !opt->linear && opt->reverse_output_stage)
|
if (opt->track_linear && !opt->linear && opt->reverse_output_stage)
|
||||||
fprintf(opt->diffopt.file, "\n%s\n", opt->break_bar);
|
fprintf(opt->diffopt.file, "\n%s\n", opt->break_bar);
|
||||||
|
if (shown)
|
||||||
|
show_diff_of_diff(opt);
|
||||||
opt->loginfo = NULL;
|
opt->loginfo = NULL;
|
||||||
maybe_flush_or_die(opt->diffopt.file, "stdout");
|
maybe_flush_or_die(opt->diffopt.file, "stdout");
|
||||||
opt->diffopt.no_free = no_free;
|
opt->diffopt.no_free = no_free;
|
||||||
|
|
||||||
diff_free(&opt->diffopt);
|
diff_free(&opt->diffopt);
|
||||||
return shown;
|
return shown;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2482,13 +2482,37 @@ test_expect_success 'interdiff: reroll-count with a integer' '
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success 'interdiff: solo-patch' '
|
test_expect_success 'interdiff: solo-patch' '
|
||||||
cat >expect <<-\EOF &&
|
|
||||||
+fleep
|
|
||||||
|
|
||||||
EOF
|
|
||||||
git format-patch --interdiff=boop~2 -1 boop &&
|
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
|
test_cmp expect actual
|
||||||
'
|
'
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue