[PATCH v5 25/29] t3440: test --trailer without values

Li Chen
2025-10-22T05:44:35Z

Add a regression test to ensure git
rebase --trailer accepts trailers without
values while preserving the separator’s
trailing space in the recorded message.

Signed-off-by: Li Chen <chenl311@chinatelecom.cn>
---
t/t3440-rebase-trailer.sh | 10 ++++++++++
1 file changed, 10 insertions(+)

diff --git a/t/t3440-rebase-trailer.sh b/t/t3440-rebase-trailer.sh
index 4b0b0ee2d3..bed6955001 100755
--- a/t/t3440-rebase-trailer.sh
+++ b/t/t3440-rebase-trailer.sh
@@ -50,6 +50,16 @@ test_expect_success 'reject trailer with missing key before separator' '
test_grep "missing key before separator" err
'

+test_expect_success 'allow trailer with missing value after separator' '
+ git rebase -m --trailer "Acked-by:" HEAD~1 third &&
+ sed -e "s/_/ /g" <<-\EOF >expect &&
+ third
+
+ Acked-by:_
+ EOF
+ test_commit_message HEAD expect
+'
+
test_expect_success 'CLI trailer duplicates allowed; replace policy keeps last' '
git -c trailer.Bug.ifexists=replace -c trailer.Bug.ifmissing=add \
rebase -m --trailer "Bug: 123" --trailer "Bug: 456" HEAD~1 third &&
--
2.51.0