{"thread":{"id":"66171","subject":"[PATCH] t1401: test symbolic-ref exit codes on a non-symbolic ref","startedAt":"2026-08-13T21:12:36Z","lastAt":"2026-08-31T06:20:07Z","messageCount":11,"participants":["Nikolaus Schuetz via GitGitGadget","Patrick Steinhardt","Nikolaus Schuetz","Junio C Hamano","Phillip Wood"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"550580","messageId":"pull.2204.git.1786655554197.gitgitgadget@gmail.com","threadId":"66171","inReplyTo":null,"subject":"[PATCH] t1401: test symbolic-ref exit codes on a non-symbolic ref","fromName":"Nikolaus Schuetz via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-08-13T21:12:33Z","receivedAt":"2026-08-13T21:12:36Z","isPatch":true,"body":"From: Nikolaus Schuetz <nikolauspschuetz@gmail.com>\n\ngit-symbolic-ref(1) documents that reading a name that is not a\nsymbolic ref exits with a non-zero status, and that --quiet does so\nsilently rather than printing a diagnostic.  This was not tested.\n\nCheck that querying a non-symbolic ref exits 128 with the usual\n\"is not a symbolic ref\" message, and that --quiet instead exits 1\nwith no output.\n\nSigned-off-by: Nikolaus Schuetz <nikolauspschuetz@gmail.com>\n---\n    t1401: test symbolic-ref exit codes on a non-symbolic ref\n    \n    git-symbolic-ref(1) documents that reading a name that is not a symbolic\n    ref exits with a non-zero status, and that --quiet does so silently\n    rather than printing a diagnostic. This exit-code contract was untested.\n    \n    This adds two tests: querying a non-symbolic ref exits 128 with the\n    usual \"is not a symbolic ref\" message, and --quiet instead exits 1 with\n    no output.\n    \n    Test-only; documents existing behaviour, in the spirit of 919eb8ace\n    (t1402: check for refs ending with a dot).\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-2204%2Fnikolauspschuetz%2Fns%2Ft1401-symbolic-ref-quiet-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2204/nikolauspschuetz/ns/t1401-symbolic-ref-quiet-v1\nPull-Request: https://github.com/gitgitgadget/git/pull/2204\n\n t/t1401-symbolic-ref.sh | 10 ++++++++++\n 1 file changed, 10 insertions(+)\n\ndiff --git a/t/t1401-symbolic-ref.sh b/t/t1401-symbolic-ref.sh\nindex a2a7e94716..602db6d080 100755\n--- a/t/t1401-symbolic-ref.sh\n+++ b/t/t1401-symbolic-ref.sh\n@@ -38,6 +38,16 @@ test_expect_success 'symbolic-ref refuses bare sha1' '\n \n reset_to_sane\n \n+test_expect_success 'symbolic-ref reports a non-symbolic ref with exit code 128' '\n+\ttest_expect_code 128 git symbolic-ref refs/heads/foo 2>err &&\n+\ttest_grep \"is not a symbolic ref\" err\n+'\n+\n+test_expect_success 'symbolic-ref -q is silent and exits 1 on a non-symbolic ref' '\n+\ttest_expect_code 1 git symbolic-ref -q refs/heads/foo 2>err &&\n+\ttest_must_be_empty err\n+'\n+\n test_expect_success 'HEAD cannot be removed' '\n \ttest_must_fail git symbolic-ref -d HEAD\n '\n\nbase-commit: 745601a9a94110d74769ab605ccd4f61339758d2\n-- \ngitgitgadget\n"},{"id":"550801","messageId":"aoWSqYvANg5AmuCi@pks.im","threadId":"66171","inReplyTo":"pull.2204.git.1786655554197.gitgitgadget@gmail.com","subject":"Re: [PATCH] t1401: test symbolic-ref exit codes on a non-symbolic ref","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-08-19T11:25:29Z","receivedAt":"2026-08-19T11:25:38Z","isPatch":true,"body":"On Thu, Aug 13, 2026 at 09:12:33PM +0000, Nikolaus Schuetz via GitGitGadget wrote:\n> From: Nikolaus Schuetz <nikolauspschuetz@gmail.com>\n> \n> git-symbolic-ref(1) documents that reading a name that is not a\n> symbolic ref exits with a non-zero status, and that --quiet does so\n> silently rather than printing a diagnostic.  This was not tested.\n\nOut of curiosity, what made you address these gaps in particular? Is\nthere any motivation, or are you just picking random things to work on?\n\n> Check that querying a non-symbolic ref exits 128 with the usual\n> \"is not a symbolic ref\" message, and that --quiet instead exits 1\n> with no output.\n\nThis is testing the status quo, but what I think would be good to\nresearch in this context is why the error codes are different in the\nfirst place. I personally find that quite a bit puzzling, as my\nexpectation would be that \"--quiet\" really only impacts whether we print\nanything or not. That it also changes the error code is weird.\n\n> diff --git a/t/t1401-symbolic-ref.sh b/t/t1401-symbolic-ref.sh\n> index a2a7e94716..602db6d080 100755\n> --- a/t/t1401-symbolic-ref.sh\n> +++ b/t/t1401-symbolic-ref.sh\n> @@ -38,6 +38,16 @@ test_expect_success 'symbolic-ref refuses bare sha1' '\n>  \n>  reset_to_sane\n>  \n> +test_expect_success 'symbolic-ref reports a non-symbolic ref with exit code 128' '\n> +\ttest_expect_code 128 git symbolic-ref refs/heads/foo 2>err &&\n> +\ttest_grep \"is not a symbolic ref\" err\n> +'\n> +\n> +test_expect_success 'symbolic-ref -q is silent and exits 1 on a non-symbolic ref' '\n> +\ttest_expect_code 1 git symbolic-ref -q refs/heads/foo 2>err &&\n> +\ttest_must_be_empty err\n> +'\n\nDo we also want to verify that stdout is empty in both cases?\n\nThanks!\n\nPatrick\n"},{"id":"550911","messageId":"20260820151325.58087-1-nikolauspschuetz@gmail.com","threadId":"66171","inReplyTo":"aoWSqYvANg5AmuCi@pks.im","subject":"Re: [PATCH] t1401: test symbolic-ref exit codes on a non-symbolic ref","fromName":"Nikolaus Schuetz","fromEmail":"nikolauspschuetz@gmail.com","sentAt":"2026-08-20T15:13:19Z","receivedAt":"2026-08-20T15:13:34Z","isPatch":true,"body":"> Out of curiosity, what made you address these gaps in particular? Is\n> there any motivation, or are you just picking random things to work on?\n\nNot random -- I've been going through git commands, checking whether the\nbehavior their man pages promise is actually exercised from t/, and\nfilling the gaps. The idea is to pin the documented contract in a test so\na later refactor can't quietly change it. git-symbolic-ref(1) spells out\nboth the exit status and the --quiet silence, but neither was tested, so\nthey stood out.\n\n> This is testing the status quo, but what I think would be good to\n> research in this context is why the error codes are different in the\n> first place.\n\nAgreed it's surprising, though it's not unique to symbolic-ref: git\nrev-parse --verify --quiet does the same thing (exit 1 and silent, vs a\nfatal 128 without --quiet). It falls out of how the two paths report in\ncheck_symref() (builtin/symbolic-ref.c): the non-quiet path calls die(),\nwhich always exits 128, while --quiet can't die() -- that would print --\nso it returns 1.\n\n> Do we also want to verify that stdout is empty in both cases?\n\nGreat idea. I've revised the added tests to redirect stdout and check\nfor empty stdout in both cases.\n\nThanks,\nNikolaus\n"},{"id":"550953","messageId":"pull.2204.v2.git.1787264402361.gitgitgadget@gmail.com","threadId":"66171","inReplyTo":"pull.2204.git.1786655554197.gitgitgadget@gmail.com","subject":"[PATCH v2] t1401: check symbolic-ref exit codes and --quiet silence","fromName":"Nikolaus Schuetz via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-08-20T22:20:02Z","receivedAt":"2026-08-20T22:20:04Z","isPatch":true,"body":"From: Nikolaus Schuetz <nikolauspschuetz@gmail.com>\n\ngit-symbolic-ref(1) documents that reading a name that is not a\nsymbolic ref exits non-zero, and that --quiet does so silently.\nTests such as t2020 and t5621 already rely on \"symbolic-ref -q HEAD\"\nfailing on a detached HEAD, but none pins the exact exit codes or\nchecks that --quiet actually suppresses the diagnostic.\n\nAssert that a non-symbolic ref exits 128 with the \"is not a symbolic\nref\" message, and that --quiet instead exits 1 with no output.\n\nSigned-off-by: Nikolaus Schuetz <nikolauspschuetz@gmail.com>\n---\n    t1401: test symbolic-ref exit codes on a non-symbolic ref\n    \n    git-symbolic-ref(1) documents that reading a name that is not a symbolic\n    ref exits with a non-zero status, and that --quiet does so silently\n    rather than printing a diagnostic. This exit-code contract was untested.\n    \n    This adds two tests: querying a non-symbolic ref exits 128 with the\n    usual \"is not a symbolic ref\" message, and --quiet instead exits 1 with\n    no output.\n    \n    Test-only; documents existing behaviour, in the spirit of 919eb8ace\n    (t1402: check for refs ending with a dot).\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-2204%2Fnikolauspschuetz%2Fns%2Ft1401-symbolic-ref-quiet-v2\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2204/nikolauspschuetz/ns/t1401-symbolic-ref-quiet-v2\nPull-Request: https://github.com/gitgitgadget/git/pull/2204\n\nRange-diff vs v1:\n\n 1:  345e664a52 ! 1:  22694da869 t1401: test symbolic-ref exit codes on a non-symbolic ref\n     @@ Metadata\n      Author: Nikolaus Schuetz <nikolauspschuetz@gmail.com>\n      \n       ## Commit message ##\n     -    t1401: test symbolic-ref exit codes on a non-symbolic ref\n     +    t1401: check symbolic-ref exit codes and --quiet silence\n      \n          git-symbolic-ref(1) documents that reading a name that is not a\n     -    symbolic ref exits with a non-zero status, and that --quiet does so\n     -    silently rather than printing a diagnostic.  This was not tested.\n     +    symbolic ref exits non-zero, and that --quiet does so silently.\n     +    Tests such as t2020 and t5621 already rely on \"symbolic-ref -q HEAD\"\n     +    failing on a detached HEAD, but none pins the exact exit codes or\n     +    checks that --quiet actually suppresses the diagnostic.\n      \n     -    Check that querying a non-symbolic ref exits 128 with the usual\n     -    \"is not a symbolic ref\" message, and that --quiet instead exits 1\n     -    with no output.\n     +    Assert that a non-symbolic ref exits 128 with the \"is not a symbolic\n     +    ref\" message, and that --quiet instead exits 1 with no output.\n      \n          Signed-off-by: Nikolaus Schuetz <nikolauspschuetz@gmail.com>\n      \n     @@ t/t1401-symbolic-ref.sh: test_expect_success 'symbolic-ref refuses bare sha1' '\n       reset_to_sane\n       \n      +test_expect_success 'symbolic-ref reports a non-symbolic ref with exit code 128' '\n     -+\ttest_expect_code 128 git symbolic-ref refs/heads/foo 2>err &&\n     ++\ttest_expect_code 128 git symbolic-ref refs/heads/foo >out 2>err &&\n     ++\ttest_must_be_empty out &&\n      +\ttest_grep \"is not a symbolic ref\" err\n      +'\n      +\n      +test_expect_success 'symbolic-ref -q is silent and exits 1 on a non-symbolic ref' '\n     -+\ttest_expect_code 1 git symbolic-ref -q refs/heads/foo 2>err &&\n     ++\ttest_expect_code 1 git symbolic-ref -q refs/heads/foo >out 2>err &&\n     ++\ttest_must_be_empty out &&\n      +\ttest_must_be_empty err\n      +'\n      +\n\n\n t/t1401-symbolic-ref.sh | 12 ++++++++++++\n 1 file changed, 12 insertions(+)\n\ndiff --git a/t/t1401-symbolic-ref.sh b/t/t1401-symbolic-ref.sh\nindex a2a7e94716..6fad83ade8 100755\n--- a/t/t1401-symbolic-ref.sh\n+++ b/t/t1401-symbolic-ref.sh\n@@ -38,6 +38,18 @@ test_expect_success 'symbolic-ref refuses bare sha1' '\n \n reset_to_sane\n \n+test_expect_success 'symbolic-ref reports a non-symbolic ref with exit code 128' '\n+\ttest_expect_code 128 git symbolic-ref refs/heads/foo >out 2>err &&\n+\ttest_must_be_empty out &&\n+\ttest_grep \"is not a symbolic ref\" err\n+'\n+\n+test_expect_success 'symbolic-ref -q is silent and exits 1 on a non-symbolic ref' '\n+\ttest_expect_code 1 git symbolic-ref -q refs/heads/foo >out 2>err &&\n+\ttest_must_be_empty out &&\n+\ttest_must_be_empty err\n+'\n+\n test_expect_success 'HEAD cannot be removed' '\n \ttest_must_fail git symbolic-ref -d HEAD\n '\n\nbase-commit: 745601a9a94110d74769ab605ccd4f61339758d2\n-- \ngitgitgadget\n"},{"id":"551144","messageId":"aoyBxOCdAq3qeAvW@pks.im","threadId":"66171","inReplyTo":"pull.2204.v2.git.1787264402361.gitgitgadget@gmail.com","subject":"Re: [PATCH v2] t1401: check symbolic-ref exit codes and --quiet silence","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-08-24T17:39:16Z","receivedAt":"2026-08-24T17:39:27Z","isPatch":true,"body":"On Thu, Aug 20, 2026 at 10:20:02PM +0000, Nikolaus Schuetz via GitGitGadget wrote:\n> From: Nikolaus Schuetz <nikolauspschuetz@gmail.com>\n> \n> git-symbolic-ref(1) documents that reading a name that is not a\n> symbolic ref exits non-zero, and that --quiet does so silently.\n> Tests such as t2020 and t5621 already rely on \"symbolic-ref -q HEAD\"\n> failing on a detached HEAD, but none pins the exact exit codes or\n> checks that --quiet actually suppresses the diagnostic.\n> \n> Assert that a non-symbolic ref exits 128 with the \"is not a symbolic\n> ref\" message, and that --quiet instead exits 1 with no output.\n\nI'm still not completely sold that this difference is intentional. As\nyou mentioned elsewhere, in one code path we use `exit(1)` and in the\nother we use `die(...)` to print an error message, which returs 128. But\nthat to me feels more like nobody noticed that those return different\nerror codes rather than an intentional difference in design, so casting\nthat behaviour into stone with new tests feels wrong to me.\n\nI'd suggest that we either:\n\n  - Continue not checking for the exact error code.\n\n  - Adapt the `exit(1)` to instead be `die(NULL)` so that we have the\n    same error code across both code paths and then verify that both\n    have the same error code.\n\nThanks!\n\nPatrick\n"},{"id":"551147","messageId":"xmqqbjarqswj.fsf@gitster.g","threadId":"66171","inReplyTo":"aoyBxOCdAq3qeAvW@pks.im","subject":"Re: [PATCH v2] t1401: check symbolic-ref exit codes and --quiet silence","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-08-24T18:23:40Z","receivedAt":"2026-08-24T18:23:43Z","isPatch":true,"body":"Patrick Steinhardt <ps@pks.im> writes:\n\n> I'm still not completely sold that this difference is intentional. As\n> you mentioned elsewhere, in one code path we use `exit(1)` and in the\n> other we use `die(...)` to print an error message, which returs 128. But\n> that to me feels more like nobody noticed that those return different\n> error codes rather than an intentional difference in design, so casting\n> that behaviour into stone with new tests feels wrong to me.\n\nI tend to agree.  The choice of 1 would have been more about \"we\nneed to exit with non-zero status\" than \"we need to use something\ndifferent from what is used by die()\".\n\n> I'd suggest that we either:\n>\n>   - Continue not checking for the exact error code.\n>\n>   - Adapt the `exit(1)` to instead be `die(NULL)` so that we have the\n>     same error code across both code paths and then verify that both\n>     have the same error code.\n\nBoth sounds very sensible.\n\nEspecially the former to avoid overspecifying what does not matter\nin the end.\n\nThanks.\n"},{"id":"551148","messageId":"9b5d2c16-3e95-4e3c-8cd9-9c25842bbb4e@gmail.com","threadId":"66171","inReplyTo":"xmqqbjarqswj.fsf@gitster.g","subject":"Re: [PATCH v2] t1401: check symbolic-ref exit codes and --quiet silence","fromName":"Phillip Wood","fromEmail":"phillip.wood123@gmail.com","sentAt":"2026-08-24T18:35:03Z","receivedAt":"2026-08-24T18:35:11Z","isPatch":true,"body":"On 24/08/2026 19:23, Junio C Hamano wrote:\n> Patrick Steinhardt <ps@pks.im> writes:\n> \n>> I'm still not completely sold that this difference is intentional. As\n>> you mentioned elsewhere, in one code path we use `exit(1)` and in the\n>> other we use `die(...)` to print an error message, which returs 128. But\n>> that to me feels more like nobody noticed that those return different\n>> error codes rather than an intentional difference in design, so casting\n>> that behaviour into stone with new tests feels wrong to me.\n> \n> I tend to agree.  The choice of 1 would have been more about \"we\n> need to exit with non-zero status\" than \"we need to use something\n> different from what is used by die()\".\n\nI'd always assumed the difference was to allow scripts to distinguish \nbetween an invalid option and the ref not existing, like \"git rev-parse \n--quiet --verify\" and \"git show-ref --quiet --verify\".\n\nThanks\n\nPhillip\n\n> \n>> I'd suggest that we either:\n>>\n>>    - Continue not checking for the exact error code.\n>>\n>>    - Adapt the `exit(1)` to instead be `die(NULL)` so that we have the\n>>      same error code across both code paths and then verify that both\n>>      have the same error code.\n> \n> Both sounds very sensible.\n> \n> Especially the former to avoid overspecifying what does not matter\n> in the end.\n> \n> Thanks.\n> \n\n"},{"id":"551162","messageId":"20260824230527.24163-1-nikolauspschuetz@gmail.com","threadId":"66171","inReplyTo":"xmqqbjarqswj.fsf@gitster.g","subject":"Re: [PATCH v2] t1401: check symbolic-ref exit codes and --quiet silence","fromName":"Nikolaus Schuetz","fromEmail":"nikolauspschuetz@gmail.com","sentAt":"2026-08-24T23:05:27Z","receivedAt":"2026-08-24T23:05:41Z","isPatch":true,"body":"I would favor continuing to not test for the exact error code, and\nwould rather not disturb anything scripts may already rely on.\n\nIn either case the git-symbolic-ref.adoc NOTES are out of sync with the\nactual behavior:\n\n  'git symbolic-ref' will exit with status 0 [...], with status 1 if the\n  requested name is not a symbolic ref, or 128 if another error occurs.\n\nTo describe the actual behavior:\n\n  'git symbolic-ref' will exit with status 0 if the contents of the\n  symbolic ref were printed correctly, with status 1 if the requested\n  name is not a symbolic ref and --quiet was given, or with status 128\n  if it is not a symbolic ref and --quiet was not given, or another\n  error occurs.\n\nIf that sounds OK I can update the adoc and call it good.\n\nThanks,\nNikolaus\n"},{"id":"551163","messageId":"xmqqfr03oyik.fsf@gitster.g","threadId":"66171","inReplyTo":"20260824230527.24163-1-nikolauspschuetz@gmail.com","subject":"Re: [PATCH v2] t1401: check symbolic-ref exit codes and --quiet silence","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-08-25T00:05:23Z","receivedAt":"2026-08-25T00:05:26Z","isPatch":true,"body":"Nikolaus Schuetz <nikolauspschuetz@gmail.com> writes:\n\n> I would favor continuing to not test for the exact error code, and\n> would rather not disturb anything scripts may already rely on.\n>\n> In either case the git-symbolic-ref.adoc NOTES are out of sync with the\n> actual behavior:\n>\n>   'git symbolic-ref' will exit with status 0 [...], with status 1 if the\n>   requested name is not a symbolic ref, or 128 if another error occurs.\n>\n> To describe the actual behavior:\n>\n>   'git symbolic-ref' will exit with status 0 if the contents of the\n>   symbolic ref were printed correctly, with status 1 if the requested\n>   name is not a symbolic ref and --quiet was given, or with status 128\n>   if it is not a symbolic ref and --quiet was not given, or another\n>   error occurs.\n>\n> If that sounds OK I can update the adoc and call it good.\n\nThis is the kind of \"casting wrong behaviour into stone by either\ndocumentation or tests\" that I advised against in my earlier\nmessage.\n"},{"id":"551296","messageId":"pull.2204.v3.git.1787763107646.gitgitgadget@gmail.com","threadId":"66171","inReplyTo":"pull.2204.git.1786655554197.gitgitgadget@gmail.com","subject":"[PATCH v3] t1401: check symbolic-ref failure and --quiet silence on a non-symbolic ref","fromName":"Nikolaus Schuetz via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-08-26T16:51:47Z","receivedAt":"2026-08-26T16:51:59Z","isPatch":true,"body":"From: Nikolaus Schuetz <nikolauspschuetz@gmail.com>\n\ngit-symbolic-ref(1) documents that reading a name that is not a\nsymbolic ref fails, and that --quiet does so silently.  Tests such as\nt2020 and t5621 already rely on \"symbolic-ref -q HEAD\" failing on a\ndetached HEAD, but none checks that the plain form reports the error\nor that --quiet stays silent.\n\nAssert that a non-symbolic ref fails with the \"is not a symbolic ref\"\nmessage, and that --quiet fails with no output.  Use test_must_fail\nrather than pinning the exact exit codes, which are documented but not\nworth freezing in the test.\n\nSigned-off-by: Nikolaus Schuetz <nikolauspschuetz@gmail.com>\n---\n    t1401: test symbolic-ref exit codes on a non-symbolic ref\n    \n    git-symbolic-ref(1) documents that reading a name that is not a symbolic\n    ref exits with a non-zero status, and that --quiet does so silently\n    rather than printing a diagnostic. This exit-code contract was untested.\n    \n    This adds two tests: querying a non-symbolic ref exits 128 with the\n    usual \"is not a symbolic ref\" message, and --quiet instead exits 1 with\n    no output.\n    \n    Test-only; documents existing behaviour, in the spirit of 919eb8ace\n    (t1402: check for refs ending with a dot).\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-2204%2Fnikolauspschuetz%2Fns%2Ft1401-symbolic-ref-quiet-v3\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2204/nikolauspschuetz/ns/t1401-symbolic-ref-quiet-v3\nPull-Request: https://github.com/gitgitgadget/git/pull/2204\n\nRange-diff vs v2:\n\n 1:  22694da869 ! 1:  0391dcceef t1401: check symbolic-ref exit codes and --quiet silence\n     @@ Metadata\n      Author: Nikolaus Schuetz <nikolauspschuetz@gmail.com>\n      \n       ## Commit message ##\n     -    t1401: check symbolic-ref exit codes and --quiet silence\n     +    t1401: check symbolic-ref failure and --quiet silence on a non-symbolic ref\n      \n          git-symbolic-ref(1) documents that reading a name that is not a\n     -    symbolic ref exits non-zero, and that --quiet does so silently.\n     -    Tests such as t2020 and t5621 already rely on \"symbolic-ref -q HEAD\"\n     -    failing on a detached HEAD, but none pins the exact exit codes or\n     -    checks that --quiet actually suppresses the diagnostic.\n     +    symbolic ref fails, and that --quiet does so silently.  Tests such as\n     +    t2020 and t5621 already rely on \"symbolic-ref -q HEAD\" failing on a\n     +    detached HEAD, but none checks that the plain form reports the error\n     +    or that --quiet stays silent.\n      \n     -    Assert that a non-symbolic ref exits 128 with the \"is not a symbolic\n     -    ref\" message, and that --quiet instead exits 1 with no output.\n     +    Assert that a non-symbolic ref fails with the \"is not a symbolic ref\"\n     +    message, and that --quiet fails with no output.  Use test_must_fail\n     +    rather than pinning the exact exit codes, which are documented but not\n     +    worth freezing in the test.\n      \n          Signed-off-by: Nikolaus Schuetz <nikolauspschuetz@gmail.com>\n      \n     @@ t/t1401-symbolic-ref.sh: test_expect_success 'symbolic-ref refuses bare sha1' '\n       \n       reset_to_sane\n       \n     -+test_expect_success 'symbolic-ref reports a non-symbolic ref with exit code 128' '\n     -+\ttest_expect_code 128 git symbolic-ref refs/heads/foo >out 2>err &&\n     ++test_expect_success 'symbolic-ref reports a non-symbolic ref' '\n     ++\ttest_must_fail git symbolic-ref refs/heads/foo >out 2>err &&\n      +\ttest_must_be_empty out &&\n      +\ttest_grep \"is not a symbolic ref\" err\n      +'\n      +\n     -+test_expect_success 'symbolic-ref -q is silent and exits 1 on a non-symbolic ref' '\n     -+\ttest_expect_code 1 git symbolic-ref -q refs/heads/foo >out 2>err &&\n     ++test_expect_success 'symbolic-ref -q is silent on a non-symbolic ref' '\n     ++\ttest_must_fail git symbolic-ref -q refs/heads/foo >out 2>err &&\n      +\ttest_must_be_empty out &&\n      +\ttest_must_be_empty err\n      +'\n\n\n t/t1401-symbolic-ref.sh | 12 ++++++++++++\n 1 file changed, 12 insertions(+)\n\ndiff --git a/t/t1401-symbolic-ref.sh b/t/t1401-symbolic-ref.sh\nindex a2a7e94716..fd3aa89a91 100755\n--- a/t/t1401-symbolic-ref.sh\n+++ b/t/t1401-symbolic-ref.sh\n@@ -38,6 +38,18 @@ test_expect_success 'symbolic-ref refuses bare sha1' '\n \n reset_to_sane\n \n+test_expect_success 'symbolic-ref reports a non-symbolic ref' '\n+\ttest_must_fail git symbolic-ref refs/heads/foo >out 2>err &&\n+\ttest_must_be_empty out &&\n+\ttest_grep \"is not a symbolic ref\" err\n+'\n+\n+test_expect_success 'symbolic-ref -q is silent on a non-symbolic ref' '\n+\ttest_must_fail git symbolic-ref -q refs/heads/foo >out 2>err &&\n+\ttest_must_be_empty out &&\n+\ttest_must_be_empty err\n+'\n+\n test_expect_success 'HEAD cannot be removed' '\n \ttest_must_fail git symbolic-ref -d HEAD\n '\n\nbase-commit: 745601a9a94110d74769ab605ccd4f61339758d2\n-- \ngitgitgadget\n"},{"id":"551500","messageId":"apUdDyG98D5upbhj@pks.im","threadId":"66171","inReplyTo":"pull.2204.v3.git.1787763107646.gitgitgadget@gmail.com","subject":"Re: [PATCH v3] t1401: check symbolic-ref failure and --quiet silence on a non-symbolic ref","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-08-31T06:19:59Z","receivedAt":"2026-08-31T06:20:07Z","isPatch":true,"body":"On Wed, Aug 26, 2026 at 04:51:47PM +0000, Nikolaus Schuetz via GitGitGadget wrote:\n> From: Nikolaus Schuetz <nikolauspschuetz@gmail.com>\n> \n> git-symbolic-ref(1) documents that reading a name that is not a\n> symbolic ref fails, and that --quiet does so silently.  Tests such as\n> t2020 and t5621 already rely on \"symbolic-ref -q HEAD\" failing on a\n> detached HEAD, but none checks that the plain form reports the error\n> or that --quiet stays silent.\n> \n> Assert that a non-symbolic ref fails with the \"is not a symbolic ref\"\n> message, and that --quiet fails with no output.  Use test_must_fail\n> rather than pinning the exact exit codes, which are documented but not\n> worth freezing in the test.\n\nDocumented sure, but the behaviour does not match the documentation:\n\n  git symbolic-ref will exit with status 0 if the contents of the\n  symbolic ref were printed correctly, with status 1 if the requested\n  name is not a symbolic ref, or 128 if another error occurs.\n\nSo in theory we should always exit with 1 in case the refname is not a\nsymbolic reference, no matter whether the user passes \"--quiet\" or not.\n\nAnyway, we're not asserting the current broken behaviour in the new\ntests anymore, so I think that this version is good enough. Thanks!\n\nPatrick\n"}]}