From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Subject: [PATCH 2/2] format-patch: move range/inter diff at the end of a single patch output
Date: Thu, 23 May 2024 15:50:07 -0700 [thread overview]
Message-ID: <20240523225007.2871766-3-gitster@pobox.com> (raw)
In-Reply-To: <20240523225007.2871766-1-gitster@pobox.com>
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.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
log-tree.c | 7 +++----
t/t4014-format-patch.sh | 17 +++++++++++------
2 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/log-tree.c b/log-tree.c
index e7cd2c491f..f28c4d0bb0 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -684,7 +684,6 @@ static void show_diff_of_diff(struct rev_info *opt)
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);
@@ -704,7 +703,6 @@ static void show_diff_of_diff(struct rev_info *opt)
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
@@ -903,8 +901,6 @@ void show_log(struct rev_info *opt)
strbuf_release(&msgbuf);
free(ctx.notes_message);
free(ctx.after_subject);
-
- show_diff_of_diff(opt);
}
int log_tree_diff_flush(struct rev_info *opt)
@@ -1176,6 +1172,9 @@ int log_tree_commit(struct rev_info *opt, struct commit *commit)
opt->loginfo = NULL;
maybe_flush_or_die(opt->diffopt.file, "stdout");
opt->diffopt.no_free = no_free;
+ if (shown)
+ show_diff_of_diff(opt);
+
diff_free(&opt->diffopt);
return shown;
}
diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh
index ba85b582c5..c0c5eccb7c 100755
--- a/t/t4014-format-patch.sh
+++ b/t/t4014-format-patch.sh
@@ -2482,13 +2482,18 @@ 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 "Interdiff:" &&
+ sed -e "s/^/ /" inter
+ } >expect &&
test_cmp expect actual
'
--
2.45.1-246-gb9cfe4845c
next prev parent reply other threads:[~2024-05-23 22:50 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-23 22:50 [PATCH 0/2] give range-diff at the end of single patch output Junio C Hamano
2024-05-23 22:50 ` [PATCH 1/2] show_log: factor out interdiff/range-diff generation Junio C Hamano
2024-05-23 22:50 ` Junio C Hamano [this message]
2024-05-24 11:14 ` [PATCH 2/2] format-patch: move range/inter diff at the end of a single patch output Patrick Steinhardt
2024-05-24 21:46 ` Junio C Hamano
2024-05-27 5:19 ` Patrick Steinhardt
2024-05-27 12:59 ` Dragan Simic
2024-05-27 17:43 ` Junio C Hamano
2024-05-28 13:27 ` Patrick Steinhardt
2024-05-28 16:50 ` Junio C Hamano
2024-05-29 5:33 ` Patrick Steinhardt
2024-05-29 14:29 ` Junio C Hamano
2024-05-30 20:05 ` Dragan Simic
2024-05-24 23:02 ` [PATCH v2 " Junio C Hamano
2024-05-23 23:22 ` [PATCH 0/2] give range-diff at the end of " Dragan Simic
2024-05-23 23:25 ` Junio C Hamano
2024-05-23 23:35 ` Dragan Simic
2024-05-24 3:56 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240523225007.2871766-3-gitster@pobox.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).