From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Subject: [PATCH v2 1/5] t4204: patch-id supports various input format
Date: Mon, 29 Jul 2024 18:17:34 -0700 [thread overview]
Message-ID: <20240730011738.4032377-2-gitster@pobox.com> (raw)
In-Reply-To: <20240730011738.4032377-1-gitster@pobox.com>
"git patch-id" was first developed to read from "git diff-tree
--stdin -p" output. Later it was enhanced to read from "git
diff-tree --stdin -p -v", which was the downstream of an early
imitation of "git log" ("git rev-list" run in the upstream of a pipe
to feed the "diff-tree"). These days, we also read from "git
format-patch".
Their output begins slightly differently, but the patch-id computed
over them for the same commit should be the same. Ensure that we
won't accidentally break this expectation.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
t/t4204-patch-id.sh | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/t/t4204-patch-id.sh b/t/t4204-patch-id.sh
index a7fa94ce0a..1627fdda1b 100755
--- a/t/t4204-patch-id.sh
+++ b/t/t4204-patch-id.sh
@@ -114,6 +114,29 @@ test_expect_success 'patch-id supports git-format-patch output' '
test "$2" = $(git rev-parse HEAD)
'
+test_expect_success 'patch-id computes the same for various formats' '
+ # This test happens to consider "git log -p -1" output
+ # the canonical input format, so use it as the norm.
+ git log -1 -p same >log-p.output &&
+ git patch-id <log-p.output >expect &&
+
+ # format-patch begins with "From <commit object name>"
+ git format-patch -1 --stdout same >format-patch.output &&
+ git patch-id <format-patch.output >actual &&
+ test_cmp actual expect &&
+
+ # "diff-tree --stdin -p" begins with "<commit object name>"
+ same=$(git rev-parse same) &&
+ echo $same | git diff-tree --stdin -p >diff-tree.output &&
+ git patch-id <diff-tree.output >actual &&
+ test_cmp actual expect &&
+
+ # "diff-tree --stdin -v -p" begins with "commit <commit object name>"
+ echo $same | git diff-tree --stdin -p -v >diff-tree-v.output &&
+ git patch-id <diff-tree-v.output >actual &&
+ test_cmp actual expect
+'
+
test_expect_success 'whitespace is irrelevant in footer' '
get_patch_id main &&
git checkout same &&
--
2.46.0-69-gd0749fd195
next prev parent reply other threads:[~2024-07-30 1:17 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-21 23:18 [PATCH 0/5] Tighten patch header parsing in patch-id Junio C Hamano
2024-06-21 23:18 ` [PATCH 1/5] t4204: patch-id supports various input format Junio C Hamano
2024-06-21 23:18 ` [PATCH 2/5] patch-id: call flush_current_id() only when needed Junio C Hamano
2024-06-21 23:18 ` [PATCH 3/5] patch-id: make get_one_patchid() more extensible Junio C Hamano
2024-07-29 12:02 ` Patrick Steinhardt
2024-07-29 20:03 ` Junio C Hamano
2024-06-21 23:18 ` [PATCH 4/5] patch-id: rewrite code that detects the beginning of a patch Junio C Hamano
2024-07-29 12:03 ` Patrick Steinhardt
2024-06-21 23:18 ` [PATCH 5/5] patch-id: tighten code to detect the patch header Junio C Hamano
2024-07-29 12:07 ` Patrick Steinhardt
2024-07-29 20:12 ` Junio C Hamano
2024-07-30 4:55 ` Patrick Steinhardt
2024-07-30 5:12 ` Patrick Steinhardt
2024-07-30 1:17 ` [PATCH v2 0/5] Tighten patch header parsing in patch-id Junio C Hamano
2024-07-30 1:17 ` Junio C Hamano [this message]
2024-07-30 1:17 ` [PATCH v2 2/5] patch-id: call flush_current_id() only when needed Junio C Hamano
2024-07-30 1:17 ` [PATCH v2 3/5] patch-id: make get_one_patchid() more extensible Junio C Hamano
2024-07-30 1:17 ` [PATCH v2 4/5] patch-id: rewrite code that detects the beginning of a patch Junio C Hamano
2024-07-30 1:17 ` [PATCH v2 5/5] patch-id: tighten code to detect the patch header Junio C Hamano
2024-07-30 5:12 ` [PATCH v2 0/5] Tighten patch header parsing in patch-id Patrick Steinhardt
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=20240730011738.4032377-2-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).