From: Denton Liu <liu.denton@gmail.com>
To: Git Mailing List <git@vger.kernel.org>
Cc: Johannes Schindelin <Johannes.Schindelin@gmx.de>,
Thomas Gummerer <t.gummerer@gmail.com>,
Junio C Hamano <gitster@pobox.com>,
Eric Sunshine <sunshine@sunshineco.com>
Subject: [PATCH v3 08/10] range-diff: output `## Notes ##` header
Date: Wed, 20 Nov 2019 13:18:43 -0800 [thread overview]
Message-ID: <2d1c849ecc30c14ace8a99753c35c96d168347bc.1574284470.git.liu.denton@gmail.com> (raw)
In-Reply-To: <cover.1574284470.git.liu.denton@gmail.com>
When notes were included in the output of range-diff, they were just
mashed together with the rest of the commit message. As a result, users
wouldn't be able to clearly distinguish where the commit message ended
and where the notes started.
Output a `## Notes ##` header when notes are detected so that notes can
be compared more clearly.
Note that we handle case of `Notes (<ref>): -> ## Notes (<ref>) ##` with
this code as well. We can't test this in this patch, however, since
there is currently no way to pass along different notes refs to `git
log`. This will be fixed in a future patch.
Signed-off-by: Denton Liu <liu.denton@gmail.com>
---
range-diff.c | 6 ++++++
t/t3206-range-diff.sh | 14 +++++++-------
2 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/range-diff.c b/range-diff.c
index 7fed5a3b4b..623397221d 100644
--- a/range-diff.c
+++ b/range-diff.c
@@ -144,6 +144,12 @@ static int read_patches(const char *range, struct string_list *list)
strbuf_addstr(&buf, line);
strbuf_addstr(&buf, "\n\n");
strbuf_addstr(&buf, " ## Commit message ##\n");
+ } else if (starts_with(line, "Notes") &&
+ line[strlen(line) - 1] == ':') {
+ strbuf_addstr(&buf, "\n\n");
+ /* strip the trailing colon */
+ strbuf_addf(&buf, " ## %.*s ##\n",
+ (int)(strlen(line) - 1), line);
} else if (starts_with(line, " ")) {
p = line + len - 2;
while (isspace(*p) && p >= line)
diff --git a/t/t3206-range-diff.sh b/t/t3206-range-diff.sh
index 19ba644933..b936c16dd1 100755
--- a/t/t3206-range-diff.sh
+++ b/t/t3206-range-diff.sh
@@ -516,10 +516,10 @@ test_expect_success 'range-diff compares notes by default' '
2: $(test_oid t2) = 2: $(test_oid u2) s/4/A/
3: $(test_oid t3) = 3: $(test_oid u3) s/11/B/
4: $(test_oid t4) ! 4: $(test_oid u4) s/12/B/
- @@ Metadata
+ @@ Commit message
Z
- Z ## Commit message ##
- Z s/12/B/
+ Z
+ Z ## Notes ##
- topic note
+ unmodified note
Z
@@ -543,17 +543,17 @@ test_expect_success 'format-patch --range-diff compares notes by default' '
grep "= 3: .* s/11/B" 0000-* &&
grep "! 4: .* s/12/B" 0000-* &&
sed s/Z/\ /g >expect <<-EOF &&
- @@ Metadata
+ @@ Commit message
Z
- Z ## Commit message ##
- Z s/12/B/
+ Z
+ Z ## Notes ##
- topic note
+ unmodified note
Z
Z ## file ##
Z@@ file: A
EOF
- sed "/@@ Metadata/,/@@ file: A/!d" 0000-* >actual &&
+ sed "/@@ Commit message/,/@@ file: A/!d" 0000-* >actual &&
test_cmp expect actual
'
--
2.24.0.450.g7a9a4598a9
next prev parent reply other threads:[~2019-11-20 21:18 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-19 1:06 [PATCH 0/3] range-diff: don't compare notes Denton Liu
2019-11-19 1:06 ` [PATCH 1/3] t3206: remove spaces after redirect operators Denton Liu
2019-11-19 1:06 ` [PATCH 2/3] t3206: demonstrate failure with notes Denton Liu
2019-11-19 3:03 ` Junio C Hamano
2019-11-19 1:06 ` [PATCH 3/3] range-diff: use --no-notes to generate patches Denton Liu
2019-11-19 2:56 ` [PATCH 0/3] range-diff: don't compare notes Junio C Hamano
2019-11-19 23:55 ` [PATCH v2 0/8] range-diff: learn `--notes` Denton Liu
2019-11-19 23:55 ` [PATCH v2 1/8] argv-array: add space after `while` Denton Liu
2019-11-19 23:55 ` [PATCH v2 2/8] rev-list-options.txt: remove reference to --show-notes Denton Liu
2019-11-19 23:55 ` [PATCH v2 3/8] t3206: remove spaces after redirect operators Denton Liu
2019-11-20 0:20 ` Eric Sunshine
2019-11-19 23:55 ` [PATCH v2 4/8] t3206: s/expected/expect/ Denton Liu
2019-11-19 23:55 ` [PATCH v2 5/8] t3206: demonstrate current notes behavior Denton Liu
2019-11-20 4:17 ` Junio C Hamano
2019-11-19 23:55 ` [PATCH v2 6/8] range-diff: output `## Notes ##` header Denton Liu
2019-11-19 23:55 ` [PATCH v2 7/8] range-diff: passthrough --[no-]notes to `git log` Denton Liu
2019-11-20 4:26 ` Junio C Hamano
2019-11-20 19:12 ` Denton Liu
2019-11-21 12:43 ` Eric Sunshine
2019-11-21 18:35 ` Denton Liu
2019-11-19 23:55 ` [PATCH v2 8/8] format-patch: pass notes configuration to range-diff Denton Liu
2019-11-20 21:18 ` [PATCH v3 00/10] range-diff: learn `--notes` Denton Liu
2019-11-20 21:18 ` [PATCH v3 01/10] argv-array: add space after `while` Denton Liu
2019-11-20 21:18 ` [PATCH v3 02/10] rev-list-options.txt: remove reference to --show-notes Denton Liu
2019-11-20 21:18 ` [PATCH v3 03/10] pretty-options.txt: --notes accepts a ref instead of treeish Denton Liu
2019-11-20 21:18 ` [PATCH v3 04/10] t3206: remove spaces after redirect operators Denton Liu
2019-11-20 21:18 ` [PATCH v3 05/10] t3206: disable parameter substitution in heredoc Denton Liu
2019-11-20 21:18 ` [PATCH v3 06/10] t3206: s/expected/expect/ Denton Liu
2019-11-20 21:18 ` [PATCH v3 07/10] t3206: range-diff compares logs with commit notes Denton Liu
2019-11-20 21:18 ` Denton Liu [this message]
2019-11-20 21:18 ` [PATCH v3 09/10] range-diff: pass through --notes to `git log` Denton Liu
2019-11-20 21:18 ` [PATCH v3 10/10] format-patch: pass notes configuration to range-diff Denton Liu
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=2d1c849ecc30c14ace8a99753c35c96d168347bc.1574284470.git.liu.denton@gmail.com \
--to=liu.denton@gmail.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=sunshine@sunshineco.com \
--cc=t.gummerer@gmail.com \
/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).