From: Patrik Weiskircher <patrik@pspdfkit.com>
To: git@vger.kernel.org
Cc: apenwarr@gmail.com, Patrik Weiskircher <patrik@pspdfkit.com>
Subject: [PATCH 2/2] contrib/subtree: Add tests for -S/--gpg-sign
Date: Wed, 28 May 2025 09:01:16 -0400 [thread overview]
Message-ID: <20250528130116.21534-3-patrik@pspdfkit.com> (raw)
In-Reply-To: <20250528130116.21534-1-patrik@pspdfkit.com>
Make sure it works correctly.
Signed-off-by: Patrik Weiskircher <patrik@pspdfkit.com>
---
contrib/subtree/t/t7900-subtree.sh | 113 +++++++++++++++++++++++++++++
1 file changed, 113 insertions(+)
diff --git a/contrib/subtree/t/t7900-subtree.sh b/contrib/subtree/t/t7900-subtree.sh
index 3c6103f6d2..3edbb33af4 100755
--- a/contrib/subtree/t/t7900-subtree.sh
+++ b/contrib/subtree/t/t7900-subtree.sh
@@ -11,6 +11,7 @@ and push subcommands of git subtree.
TEST_DIRECTORY=$(pwd)/../../../t
. "$TEST_DIRECTORY"/test-lib.sh
+. "$TEST_DIRECTORY"/lib-gpg.sh
# Use our own wrapper around test-lib.sh's test_create_repo, in order
# to set log.date=relative. `git subtree` parses the output of `git
@@ -1563,4 +1564,116 @@ test_expect_success 'subtree descendant check' '
)
'
+test_expect_success GPG 'add subproj with GPG signing using -S flag' '
+ subtree_test_create_repo "$test_count" &&
+ subtree_test_create_repo "$test_count/sub proj" &&
+ test_create_commit "$test_count" main1 &&
+ test_create_commit "$test_count/sub proj" sub1 &&
+ (
+ cd "$test_count" &&
+ git fetch ./"sub proj" HEAD &&
+ git subtree add --prefix="sub dir" -S FETCH_HEAD &&
+ git verify-commit HEAD &&
+ test "$(last_commit_subject)" = "Add '\''sub dir/'\'' from commit '\''$(git rev-parse FETCH_HEAD)'\''"
+ )
+'
+
+test_expect_success GPG 'add subproj with GPG signing using --gpg-sign flag' '
+ subtree_test_create_repo "$test_count" &&
+ subtree_test_create_repo "$test_count/sub proj" &&
+ test_create_commit "$test_count" main1 &&
+ test_create_commit "$test_count/sub proj" sub1 &&
+ (
+ cd "$test_count" &&
+ git fetch ./"sub proj" HEAD &&
+ git subtree add --prefix="sub dir" --gpg-sign FETCH_HEAD &&
+ git verify-commit HEAD &&
+ test "$(last_commit_subject)" = "Add '\''sub dir/'\'' from commit '\''$(git rev-parse FETCH_HEAD)'\''"
+ )
+'
+
+test_expect_success GPG 'add subproj with GPG signing using specific key ID' '
+ subtree_test_create_repo "$test_count" &&
+ subtree_test_create_repo "$test_count/sub proj" &&
+ test_create_commit "$test_count" main1 &&
+ test_create_commit "$test_count/sub proj" sub1 &&
+ (
+ cd "$test_count" &&
+ git fetch ./"sub proj" HEAD &&
+ git subtree add --prefix="sub dir" -S"$GIT_COMMITTER_EMAIL" FETCH_HEAD &&
+ git verify-commit HEAD &&
+ test "$(last_commit_subject)" = "Add '\''sub dir/'\'' from commit '\''$(git rev-parse FETCH_HEAD)'\''"
+ )
+'
+
+test_expect_success GPG 'merge with GPG signing' '
+ subtree_test_create_repo "$test_count" &&
+ subtree_test_create_repo "$test_count/sub proj" &&
+ test_create_commit "$test_count" main1 &&
+ test_create_commit "$test_count/sub proj" sub1 &&
+ (
+ cd "$test_count" &&
+ git fetch ./"sub proj" HEAD &&
+ git subtree add --prefix="sub dir" FETCH_HEAD
+ ) &&
+ test_create_commit "$test_count/sub proj" sub2 &&
+ (
+ cd "$test_count" &&
+ git fetch ./"sub proj" HEAD &&
+ git subtree merge --prefix="sub dir" -S FETCH_HEAD &&
+ git verify-commit HEAD
+ )
+'
+
+test_expect_success GPG 'split with GPG signing and --rejoin' '
+ subtree_test_create_repo "$test_count" &&
+ subtree_test_create_repo "$test_count/sub proj" &&
+ test_create_commit "$test_count" main1 &&
+ test_create_commit "$test_count/sub proj" sub1 &&
+ (
+ cd "$test_count" &&
+ git fetch ./"sub proj" HEAD &&
+ git subtree add --prefix="sub dir" FETCH_HEAD
+ ) &&
+ test_create_commit "$test_count" "sub dir/main-sub1" &&
+ (
+ cd "$test_count" &&
+ git subtree split --prefix="sub dir" --rejoin -S &&
+ git verify-commit HEAD
+ )
+'
+
+test_expect_success GPG 'add with --squash and GPG signing' '
+ subtree_test_create_repo "$test_count" &&
+ subtree_test_create_repo "$test_count/sub proj" &&
+ test_create_commit "$test_count" main1 &&
+ test_create_commit "$test_count/sub proj" sub1 &&
+ (
+ cd "$test_count" &&
+ git fetch ./"sub proj" HEAD &&
+ git subtree add --prefix="sub dir" --squash -S FETCH_HEAD &&
+ git verify-commit HEAD &&
+ # With --squash, the commit subject should reference the squash commit (first parent of merge)
+ squash_commit=$(git rev-parse HEAD^2) &&
+ test "$(last_commit_subject)" = "Merge commit '\''$squash_commit'\'' as '\''sub dir'\''"
+ )
+'
+
+test_expect_success GPG 'pull with GPG signing' '
+ subtree_test_create_repo "$test_count" &&
+ subtree_test_create_repo "$test_count/sub proj" &&
+ test_create_commit "$test_count" main1 &&
+ test_create_commit "$test_count/sub proj" sub1 &&
+ (
+ cd "$test_count" &&
+ git subtree add --prefix="sub dir" ./"sub proj" HEAD
+ ) &&
+ test_create_commit "$test_count/sub proj" sub2 &&
+ (
+ cd "$test_count" &&
+ git subtree pull --prefix="sub dir" -S ./"sub proj" HEAD &&
+ git verify-commit HEAD
+ )
+'
+
test_done
--
2.49.0
next prev parent reply other threads:[~2025-05-28 13:02 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-28 13:01 [PATCH 0/2] contrib/subtree: Add -S/--gpg-sign option Patrik Weiskircher
2025-05-28 13:01 ` [PATCH 1/2] " Patrik Weiskircher
2025-05-29 23:45 ` Junio C Hamano
2025-05-28 13:01 ` Patrik Weiskircher [this message]
2025-05-29 23:15 ` [PATCH 0/2] " Junio C Hamano
2025-05-30 14:33 ` Patrik Weiskircher
2025-05-30 20:55 ` Junio C Hamano
2025-06-02 13:12 ` Patrik Weiskircher
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=20250528130116.21534-3-patrik@pspdfkit.com \
--to=patrik@pspdfkit.com \
--cc=apenwarr@gmail.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).