t7501: add tests for --amend --signoff
Add tests for amending the commit to add Signed-off-by trailer. And also to check if it does not add another trailer if one already exists. Currently, there are tests for --signoff separately in t7501, however, they are not tested with --amend. Therefore, these tests belong with other similar tests of --amend in t7501-commit-basic-functionality. Helped-by: Phillip Wood <phillip.wood123@gmail.com> Signed-off-by: Ghanshyam Thakkar <shyamthakkar001@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Ghanshyam Thakkar committed
Jan 17, 2024 at 21:43 UTC
cab11f4e4116bc2cb09fc83ed79aad4457a4e630
1 file changed
+23
-2
t/t7501-commit-basic-functionality.sh
+23
-2
@@ -3,8 +3,7 @@
3
# Copyright (c) 2007 Kristian Høgsberg <krh@redhat.com>
4
#
5
6
-# FIXME: Test the various index usages, test reflog,
7
-# signoff
6
+# FIXME: Test the various index usages, test reflog
7
8
test_description='git commit'
9
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
@@ -462,6 +461,28 @@ test_expect_success 'amend commit to fix date' '
461
462
'
463
464
+test_expect_success 'amend commit to add signoff' '
465
+
466
+ test_commit "msg" file content &&
467
+ git commit --amend --signoff &&
468
+ test_commit_message HEAD <<-EOF
469
+ msg
470
+
471
+ Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>
472
+ EOF
473
+'
474
+
475
+test_expect_success 'amend does not add signoff if it already exists' '
476
+
477
+ test_commit --signoff "tenor" file newcontent &&
478
+ git commit --amend --signoff &&
479
+ test_commit_message HEAD <<-EOF
480
+ tenor
481
+
482
+ Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>
483
+ EOF
484
+'
485
+
486
test_expect_success 'commit mentions forced date in output' '
487
git commit --amend --date=2010-01-02T03:04:05 >output &&
488
grep "Date: *Sat Jan 2 03:04:05 2010" output