From: Souma <git@5ouma.me>
To: git@vger.kernel.org
Cc: gitster@pobox.com, ps@pks.im, Souma <git@5ouma.me>
Subject: [PATCH 3/3] t345x: cover signed history rewrites
Date: Fri, 3 Jul 2026 23:50:37 +0900 [thread overview]
Message-ID: <20260703145037.69832-4-git@5ouma.me> (raw)
In-Reply-To: <20260703145037.69832-1-git@5ouma.me>
History signing needs regression coverage because these commands bypass the
usual commit machinery and create replacement commits through lower-level
APIs.
Add GPG-gated tests for config-driven signing, command-line signing,
--no-gpg-sign precedence, and signing of replayed descendants after fixup,
reword, and split.
Signed-off-by: Souma <git@5ouma.me>
---
t/t3451-history-reword.sh | 39 ++++++++++++++++++++++++++++++++++
t/t3452-history-split.sh | 44 +++++++++++++++++++++++++++++++++++++++
t/t3453-history-fixup.sh | 39 ++++++++++++++++++++++++++++++++++
3 files changed, 122 insertions(+)
diff --git a/t/t3451-history-reword.sh b/t/t3451-history-reword.sh
index de7b357685..5b41fb6489 100755
--- a/t/t3451-history-reword.sh
+++ b/t/t3451-history-reword.sh
@@ -4,6 +4,7 @@ test_description='tests for git-history reword subcommand'
. ./test-lib.sh
. "$TEST_DIRECTORY/lib-log-graph.sh"
+. "$TEST_DIRECTORY/lib-gpg.sh"
reword_with_message () {
cat >message &&
@@ -26,6 +27,37 @@ expect_log () {
test_cmp expect actual
}
+test_reword_gpg_sign () {
+ must_fail= will=will
+ if test "x$1" = "x!"
+ then
+ must_fail=test_must_fail
+ will="will not"
+ shift
+ fi
+ conf=$1
+ shift
+
+ test_expect_success GPG "reword $* with commit.gpgsign=$conf $will sign rewritten history" "
+ test_when_finished 'rm -rf repo' &&
+ git init repo &&
+ (
+ cd repo &&
+ test_commit first &&
+ test_commit second &&
+ test_commit third &&
+
+ git config commit.gpgsign $conf &&
+ reword_with_message $* HEAD~ <<-EOF &&
+ second reworded
+ EOF
+
+ $must_fail git verify-commit HEAD~ &&
+ $must_fail git verify-commit HEAD
+ )
+ "
+}
+
test_expect_success 'can reword tip of a branch' '
test_when_finished "rm -rf repo" &&
git init repo &&
@@ -77,6 +109,13 @@ test_expect_success 'can reword commit in the middle' '
)
'
+test_reword_gpg_sign ! false
+test_reword_gpg_sign true
+test_reword_gpg_sign false --gpg-sign
+test_reword_gpg_sign ! true --no-gpg-sign
+test_reword_gpg_sign ! true --gpg-sign --no-gpg-sign
+test_reword_gpg_sign false --no-gpg-sign --gpg-sign
+
test_expect_success 'can reword commit in the middle even on detached head' '
test_when_finished "rm -rf repo" &&
git init repo &&
diff --git a/t/t3452-history-split.sh b/t/t3452-history-split.sh
index 8ed0cebb50..e96f492cc6 100755
--- a/t/t3452-history-split.sh
+++ b/t/t3452-history-split.sh
@@ -4,6 +4,7 @@ test_description='tests for git-history split subcommand'
. ./test-lib.sh
. "$TEST_DIRECTORY/lib-log-graph.sh"
+. "$TEST_DIRECTORY/lib-gpg.sh"
# The fake editor takes multiple arguments, each of which represents a commit
# message. Subsequent invocations of the editor will then yield those messages
@@ -36,6 +37,42 @@ expect_tree_entries () {
test_cmp expect actual
}
+test_split_gpg_sign () {
+ must_fail= will=will
+ if test "x$1" = "x!"
+ then
+ must_fail=test_must_fail
+ will="will not"
+ shift
+ fi
+ conf=$1
+ shift
+
+ test_expect_success GPG "split $* with commit.gpgsign=$conf $will sign rewritten history" "
+ test_when_finished 'rm -rf repo' &&
+ git init repo &&
+ (
+ cd repo &&
+ test_commit initial &&
+ touch bar foo &&
+ git add . &&
+ git commit -m split-me &&
+ test_commit tip &&
+
+ git config commit.gpgsign $conf &&
+ set_fake_editor 'first' 'second' &&
+ git history split $* HEAD~ <<-EOF &&
+ y
+ n
+ EOF
+
+ $must_fail git verify-commit HEAD~2 &&
+ $must_fail git verify-commit HEAD~ &&
+ $must_fail git verify-commit HEAD
+ )
+ "
+}
+
test_expect_success 'refuses to work with merge commits' '
test_when_finished "rm -rf repo" &&
git init repo &&
@@ -141,6 +178,13 @@ test_expect_success 'can split up tip commit' '
)
'
+test_split_gpg_sign ! false
+test_split_gpg_sign true
+test_split_gpg_sign false --gpg-sign
+test_split_gpg_sign ! true --no-gpg-sign
+test_split_gpg_sign ! true --gpg-sign --no-gpg-sign
+test_split_gpg_sign false --no-gpg-sign --gpg-sign
+
test_expect_success 'can split up root commit' '
test_when_finished "rm -rf repo" &&
git init repo &&
diff --git a/t/t3453-history-fixup.sh b/t/t3453-history-fixup.sh
index 868298e248..cd20a23115 100755
--- a/t/t3453-history-fixup.sh
+++ b/t/t3453-history-fixup.sh
@@ -3,6 +3,7 @@
test_description='tests for git-history fixup subcommand'
. ./test-lib.sh
+. "$TEST_DIRECTORY/lib-gpg.sh"
fixup_with_message () {
cat >message &&
@@ -21,6 +22,37 @@ expect_changes () {
test_cmp expect actual
}
+test_fixup_gpg_sign () {
+ must_fail= will=will
+ if test "x$1" = "x!"
+ then
+ must_fail=test_must_fail
+ will="will not"
+ shift
+ fi
+ conf=$1
+ shift
+
+ test_expect_success GPG "fixup $* with commit.gpgsign=$conf $will sign rewritten history" "
+ test_when_finished 'rm -rf repo' &&
+ git init repo &&
+ (
+ cd repo &&
+ test_commit first &&
+ test_commit second &&
+ test_commit third &&
+
+ git config commit.gpgsign $conf &&
+ echo fix >>second.t &&
+ git add second.t &&
+ git history fixup $* HEAD~ &&
+
+ $must_fail git verify-commit HEAD~ &&
+ $must_fail git verify-commit HEAD
+ )
+ "
+}
+
test_expect_success 'errors on missing commit argument' '
test_when_finished "rm -rf repo" &&
git init repo &&
@@ -229,6 +261,13 @@ test_expect_success 'preserves commit message and authorship' '
)
'
+test_fixup_gpg_sign ! false
+test_fixup_gpg_sign true
+test_fixup_gpg_sign false --gpg-sign
+test_fixup_gpg_sign ! true --no-gpg-sign
+test_fixup_gpg_sign ! true --gpg-sign --no-gpg-sign
+test_fixup_gpg_sign false --no-gpg-sign --gpg-sign
+
test_expect_success 'updates all descendant branches by default' '
test_when_finished "rm -rf repo" &&
git init repo --initial-branch=main &&
--
2.55.0
prev parent reply other threads:[~2026-07-03 14:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-03 14:50 [PATCH 0/3] history: sign rewritten commits Souma
2026-07-03 14:50 ` [PATCH 1/3] builtin/history: " Souma
2026-07-03 14:50 ` [PATCH 2/3] doc: document history signing options Souma
2026-07-03 14:50 ` Souma [this message]
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=20260703145037.69832-4-git@5ouma.me \
--to=git@5ouma.me \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=ps@pks.im \
/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