{"thread":{"id":"64794","subject":"[PATCH] t0100: avoid suppressing git exit code","startedAt":"2026-01-13T18:04:20Z","lastAt":"2026-01-14T14:23:57Z","messageCount":2,"participants":["amisha","Pushkar Singh"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"533763","messageId":"20260113180409.36683-1-amishhhaaaa@gmail.com","threadId":"64794","inReplyTo":null,"subject":"[PATCH] t0100: avoid suppressing git exit code","fromName":"amisha","fromEmail":"amishhhaaaa@gmail.com","sentAt":"2026-01-13T18:04:09Z","receivedAt":"2026-01-13T18:04:20Z","isPatch":true,"sender":{"key":"amishhhaaaa@gmail.com","avatar":"https://avatars.githubusercontent.com/u/136238836?v=4"},"body":"In t0100-previous.sh, the exit code of 'git cat-file' is suppressed by\npiping it directly into grep. If git crashes, the test might not\nnotice.\n\nRedirect the output of git to a temporary file 'actual' and grep\nfrom that file instead. This ensures that the exit code of the\ngit command is properly checked.\n\nSigned-off-by: amisha <amishhhaaaa@gmail.com>\n---\n t/t0100-previous.sh | 3 ++-\n 1 file changed, 2 insertions(+), 1 deletion(-)\n\ndiff --git a/t/t0100-previous.sh b/t/t0100-previous.sh\nindex dd5d9b4e5e..ffe3fda495 100755\n--- a/t/t0100-previous.sh\n+++ b/t/t0100-previous.sh\n@@ -40,7 +40,8 @@ test_expect_success 'merge @{-1}' '\n \tgit checkout other &&\n \tgit checkout main &&\n \tgit merge @{-1} &&\n-\tgit cat-file commit HEAD | grep \"Merge branch '\\''other'\\''\"\n+\tgit cat-file commit HEAD >actual &&\n+\tgrep \"Merge branch '\\''other'\\''\" actual\n '\n \n test_expect_success 'merge @{-1}~1' '\n-- \n2.51.0\n\n"},{"id":"533826","messageId":"CALE2CrQFZngj6_NDuf0S=_-nDrrf6b6r=C9jMyEVjwMqvh6J2w@mail.gmail.com","threadId":"64794","inReplyTo":"20260113180409.36683-1-amishhhaaaa@gmail.com","subject":"Re: [PATCH] t0100: avoid suppressing git exit code","fromName":"Pushkar Singh","fromEmail":"pushkarkumarsingh1970@gmail.com","sentAt":"2026-01-14T14:23:45Z","receivedAt":"2026-01-14T14:23:57Z","isPatch":true,"sender":{"key":"pushkarkumarsingh1970@gmail.com","avatar":"https://avatars.githubusercontent.com/u/173247767?v=4"},"body":"Hi Amisha,\n\nThanks for the patch. This makes sense, since piping into grep was indeed\nsuppressing the exit status of git cat-file.\n\nOne small style suggestion. Most Git tests use the helper instead of raw\ngrep, so this could be written as:\n\n    git cat-file commit HEAD >actual &&\n    test_grep \"Merge branch 'other'\" actual\n\nThis gives nicer diagnostics on failure and is consistent with other\ntests.\n\nOther than that, the approach looks good to me.\n\nThanks,\nPushkar\n\nOn Tue, Jan 13, 2026 at 11:34 PM amisha <amishhhaaaa@gmail.com> wrote:\n>\n> In t0100-previous.sh, the exit code of 'git cat-file' is suppressed by\n> piping it directly into grep. If git crashes, the test might not\n> notice.\n>\n> Redirect the output of git to a temporary file 'actual' and grep\n> from that file instead. This ensures that the exit code of the\n> git command is properly checked.\n>\n> Signed-off-by: amisha <amishhhaaaa@gmail.com>\n> ---\n>  t/t0100-previous.sh | 3 ++-\n>  1 file changed, 2 insertions(+), 1 deletion(-)\n>\n> diff --git a/t/t0100-previous.sh b/t/t0100-previous.sh\n> index dd5d9b4e5e..ffe3fda495 100755\n> --- a/t/t0100-previous.sh\n> +++ b/t/t0100-previous.sh\n> @@ -40,7 +40,8 @@ test_expect_success 'merge @{-1}' '\n>         git checkout other &&\n>         git checkout main &&\n>         git merge @{-1} &&\n> -       git cat-file commit HEAD | grep \"Merge branch '\\''other'\\''\"\n> +       git cat-file commit HEAD >actual &&\n> +       grep \"Merge branch '\\''other'\\''\" actual\n>  '\n>\n>  test_expect_success 'merge @{-1}~1' '\n> --\n> 2.51.0\n>\n>\n"}]}