[GSoC][RFC PATCH 6/6] t4014: add tests for the new flag --subject-extra-prefix
- From
Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>
- Date
- Mar 3, 2025, 22:00 UTC
- Message-ID
- <20250303220029.10716-7-lucasseikioshiro@gmail.com>
- In-Reply-To
- <20250303220029.10716-1-lucasseikioshiro@gmail.com>
Add tests for `format-patch --subject-extra-prefix` asserting that it works correctly in the following situations:
- without other flags related to the prefix;
- with the --rfc flag, which should add RFC to the prefix;
- with the -n flag, which should add the numbering to the prefix;
- with the -v flag, which should add the patch version to the prefix;
- with the -k flag, diying as they aren't meant to be used together.
Signed-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com> --- t/t4014-format-patch.sh | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)
diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh index 884f83fb8a..1256ce2197 100755 --- a/t/t4014-format-patch.sh +++ b/t/t4014-format-patch.sh @@ -1444,6 +1444,46 @@ test_expect_success '--rfc and -k cannot be used together' ' test_cmp expect.err actual.err ' +cat >expect <<'EOF' +Subject: [EXTRA][PATCH] header with . in it +EOF +test_expect_success '--subject-extra-prefix adds extra prefix' ' + git format-patch -1 --stdout --subject-extra-prefix=EXTRA >patch && + grep ^Subject: patch >actual && + test_cmp expect actual +' + +cat >expect <<'EOF' +Subject: [EXTRA][RFC PATCH] header with . in it +EOF +test_expect_success '--subject-extra-prefix works with --rfc' ' + git format-patch --rfc -1 --stdout --subject-extra-prefix=EXTRA >patch && + grep ^Subject: patch >actual && + test_cmp expect actual +' + +cat >expect <<'EOF' +Subject: [EXTRA][PATCH 1/1] header with . in it +EOF +test_expect_success '--subject-extra-prefix works with numbered patches' ' + git format-patch -n -1 --stdout --subject-extra-prefix=EXTRA >patch && + grep ^Subject: patch >actual && + test_cmp expect actual +' + +cat >expect <<'EOF' +Subject: [EXTRA][PATCH v2] header with . in it +EOF +test_expect_success '--subject-extra-prefix works with -v' ' + git format-patch -v2 -1 --stdout --subject-extra-prefix=EXTRA >patch && + grep ^Subject: patch >actual && + test_cmp expect actual +' + +test_expect_failure '--subject-extra-prefix does not run with -k' ' + git format-patch -k -1 --stdout --subject-extra-prefix=EXTRA >/dev/null +' + test_expect_success '--from=ident notices bogus ident' ' test_must_fail git format-patch -1 --stdout --from=foo >patch '
-- 2.39.5 (Apple Git-154)