{"thread":{"id":"66684","subject":"[PATCH] t/t1467-refs-rename: Use test_must_fail in place of NOT operator","startedAt":"2026-10-27T18:48:43Z","lastAt":"2026-10-28T09:59:47Z","messageCount":3,"participants":["Hardik Kumar","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"556559","messageId":"20261028-refs-rename-test-fail-v1-1-b7458ca62149@gmail.com","threadId":"66684","inReplyTo":null,"subject":"[PATCH] t/t1467-refs-rename: Use test_must_fail in place of NOT operator","fromName":"Hardik Kumar","fromEmail":"hardikxk@gmail.com","sentAt":"2026-10-27T18:48:43Z","receivedAt":"2026-10-27T18:48:43Z","isPatch":true,"sender":{"key":"hardikxk@gmail.com","avatar":"https://avatars.githubusercontent.com/u/183656738?v=4"},"body":"All tests in `t/t1467-refs-rename.sh` use test_must_fail for verifying\nwhen a test or command is expected to fail. `test_must_fail` is used for\nall Git commands.\n\nThe use of the NOT operator is replaced with `test_must_fail` to ensure\nconsistency in the unit tests without any functional changes to the\ntests themselves.\n\nSigned-off-by: Hardik Kumar <hardikxk@gmail.com>\n---\n t/t1467-refs-rename.sh | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/t/t1467-refs-rename.sh b/t/t1467-refs-rename.sh\nindex 2b28be75c8..b7d290d05b 100755\n--- a/t/t1467-refs-rename.sh\n+++ b/t/t1467-refs-rename.sh\n@@ -88,7 +88,7 @@ test_expect_success 'rename with symbolic ref fails' '\n \t\tA=$(git rev-parse A) &&\n \t\tgit refs create refs/heads/target $A &&\n \t\tgit symbolic-ref refs/heads/symref refs/heads/target &&\n-\t\t! git refs rename refs/heads/symref refs/heads/renamed 2>err &&\n+\t\ttest_must_fail git refs rename refs/heads/symref refs/heads/renamed 2>err &&\n \t\ttest_grep \"is a symbolic ref, .* not supported\" err\n \t)\n '\n\n---\nbase-commit: 37b3475fb530c14109211faca33716a173db61ed\nchange-id: 20261028-refs-rename-test-fail-ec7a8fa74e54\n\n\n"},{"id":"556599","messageId":"xmqqld7iebhj.fsf@gitster.g","threadId":"66684","inReplyTo":"20261028-refs-rename-test-fail-v1-1-b7458ca62149@gmail.com","subject":"Re: [PATCH] t/t1467-refs-rename: Use test_must_fail in place of NOT operator","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-10-28T03:43:20Z","receivedAt":"2026-10-28T03:43:20Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Hardik Kumar <hardikxk@gmail.com> writes:\n\n> All tests in `t/t1467-refs-rename.sh` use test_must_fail for verifying\n> when a test or command is expected to fail. `test_must_fail` is used for\n> all Git commands.\n\n\"all Git commands\" that are expected to fail, right?\n\nFor two \"git\" commands that appear immediately before the line you\ntouched in the patch, test_must_fail is not used ;-)\n\n> The use of the NOT operator is replaced with `test_must_fail` to ensure\n> consistency in the unit tests without any functional changes to the\n> tests themselves.\n\nA more common way for our proposed commit log message phrase the\nabove is\n\n\tReplace the \"not\" (!) operator with `test_must_fail` to ...\n\nMore importantly, the use of test_must_fail is *NOT* about\nconsistency.  The most important reason why it is the better way to\nwrite than \"! git refs rename ...\" is that test_must_fail notices\nand fails loudly if the command line getting tested does not fail in\na graceful way.  If somebody tries to update the \"git refs\" command,\nintroduces a bug and makes it segfault when \n\n\tgit refs rename refs/heads/symref refs/heads/renamed\n\nis run, the command line prefixed with '!' will happily say \"ah, the\ncommand crashed and did not succeed, and I am happy\", but that is\nnot the kind of failing that we want to be happy with.  If you\nprefix the command line with test_must_fail, however, test_must_fail\nwould still fail when the \"git refs rename\" died with segfault or\notherwise killed by a signal.\n\nThanks.\n\n\n> Signed-off-by: Hardik Kumar <hardikxk@gmail.com>\n> ---\n>  t/t1467-refs-rename.sh | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n>\n> diff --git a/t/t1467-refs-rename.sh b/t/t1467-refs-rename.sh\n> index 2b28be75c8..b7d290d05b 100755\n> --- a/t/t1467-refs-rename.sh\n> +++ b/t/t1467-refs-rename.sh\n> @@ -88,7 +88,7 @@ test_expect_success 'rename with symbolic ref fails' '\n>  \t\tA=$(git rev-parse A) &&\n>  \t\tgit refs create refs/heads/target $A &&\n>  \t\tgit symbolic-ref refs/heads/symref refs/heads/target &&\n> -\t\t! git refs rename refs/heads/symref refs/heads/renamed 2>err &&\n> +\t\ttest_must_fail git refs rename refs/heads/symref refs/heads/renamed 2>err &&\n>  \t\ttest_grep \"is a symbolic ref, .* not supported\" err\n>  \t)\n>  '\n>\n> ---\n> base-commit: 37b3475fb530c14109211faca33716a173db61ed\n> change-id: 20261028-refs-rename-test-fail-ec7a8fa74e54\n\n"},{"id":"556631","messageId":"DMGDTKTJT5GV.27BGIN7N0K8T3@gmail.com","threadId":"66684","inReplyTo":"xmqqld7iebhj.fsf@gitster.g","subject":"Re: [PATCH] t/t1467-refs-rename: Use test_must_fail in place of NOT operator","fromName":"Hardik Kumar","fromEmail":"hardikxk@gmail.com","sentAt":"2026-10-28T09:59:47Z","receivedAt":"2026-10-28T09:59:47Z","isPatch":true,"sender":{"key":"hardikxk@gmail.com","avatar":"https://avatars.githubusercontent.com/u/183656738?v=4"},"body":"On Wed Oct 28, 2026 at 9:13 AM IST, Junio C Hamano wrote:\n> Hardik Kumar <hardikxk@gmail.com> writes:\n>\n>> All tests in `t/t1467-refs-rename.sh` use test_must_fail for verifying\n>> when a test or command is expected to fail. `test_must_fail` is used for\n>> all Git commands.\n>\n> \"all Git commands\" that are expected to fail, right?\n>\n> For two \"git\" commands that appear immediately before the line you\n> touched in the patch, test_must_fail is not used ;-)\n\nYes of course what I was trying to say here was that based on the\nRelease Notes the use of `test_must_fail` must be limited to only Git\ncommands (expected to fail). So the patch is following that principle.\n\n>> The use of the NOT operator is replaced with `test_must_fail` to ensure\n>> consistency in the unit tests without any functional changes to the\n>> tests themselves.\n>\n> A more common way for our proposed commit log message phrase the\n> above is\n>\n> \tReplace the \"not\" (!) operator with `test_must_fail` to ...\n>\n> More importantly, the use of test_must_fail is *NOT* about\n> consistency.  The most important reason why it is the better way to\n> write than \"! git refs rename ...\" is that test_must_fail notices\n> and fails loudly if the command line getting tested does not fail in\n> a graceful way.  If somebody tries to update the \"git refs\" command,\n> introduces a bug and makes it segfault when \n>\n> \tgit refs rename refs/heads/symref refs/heads/renamed\n>\n> is run, the command line prefixed with '!' will happily say \"ah, the\n> command crashed and did not succeed, and I am happy\", but that is\n> not the kind of failing that we want to be happy with.  If you\n> prefix the command line with test_must_fail, however, test_must_fail\n> would still fail when the \"git refs rename\" died with segfault or\n> otherwise killed by a signal.\n>\n> Thanks.\n\nThanks for explaining that! I will update the commit message in v2.\n\n>> Signed-off-by: Hardik Kumar <hardikxk@gmail.com>\n>> ---\n>>  t/t1467-refs-rename.sh | 2 +-\n>>  1 file changed, 1 insertion(+), 1 deletion(-)\n>>\n>> diff --git a/t/t1467-refs-rename.sh b/t/t1467-refs-rename.sh\n>> index 2b28be75c8..b7d290d05b 100755\n>> --- a/t/t1467-refs-rename.sh\n>> +++ b/t/t1467-refs-rename.sh\n>> @@ -88,7 +88,7 @@ test_expect_success 'rename with symbolic ref fails' '\n>>  \t\tA=$(git rev-parse A) &&\n>>  \t\tgit refs create refs/heads/target $A &&\n>>  \t\tgit symbolic-ref refs/heads/symref refs/heads/target &&\n>> -\t\t! git refs rename refs/heads/symref refs/heads/renamed 2>err &&\n>> +\t\ttest_must_fail git refs rename refs/heads/symref refs/heads/renamed 2>err &&\n>>  \t\ttest_grep \"is a symbolic ref, .* not supported\" err\n>>  \t)\n>>  '\n>>\n>> ---\n>> base-commit: 37b3475fb530c14109211faca33716a173db61ed\n>> change-id: 20261028-refs-rename-test-fail-ec7a8fa74e54\n\n\n\n"}]}