{"thread":{"id":"65130","subject":"[PATCH v3 0/2] t3700: modernize and fix exit code suppression","startedAt":"2026-03-03T20:40:58Z","lastAt":"2026-03-03T20:43:08Z","messageCount":3,"participants":["Siddharth Shrimali"],"isPatch":true,"patchVersion":3,"patchTotal":2},"messages":[{"id":"537731","messageId":"20260303204029.52952-1-r.siddharth.shrimali@gmail.com","threadId":"65130","inReplyTo":null,"subject":"[PATCH v3 0/2] t3700: modernize and fix exit code suppression","fromName":"Siddharth Shrimali","fromEmail":"r.siddharth.shrimali@gmail.com","sentAt":"2026-03-03T20:40:27Z","receivedAt":"2026-03-03T20:40:58Z","isPatch":true,"sender":{"key":"r.siddharth.shrimali@gmail.com","avatar":"https://avatars.githubusercontent.com/u/183274193?v=4"},"body":"This is the third version to modernize t3700 and ensure git's \nexit codes are not suppressed in pipelines.\n\nChanges in v3:\n- Split the series into two distinct patches as suggested by Junio.\n- Patch 1/2: Focuses strictly on breaking pipelines to expose git's\n  exit status and simplifying 'wc -l' logic.\n- Patch 2/2: Converts all remaining 'grep' and '! grep' calls to the\n  modern 'test_grep' and 'test_grep !' helpers.\n- Fixed trailer formatting in commit messages.\n\nSiddharth Shrimali (2):\n  t3700: avoid suppressing git's exit code\n  t3700: use test_grep helper for better diagnostics\n\n t/t3700-add.sh | 49 +++++++++++++++++++++++++++++++------------------\n 1 file changed, 31 insertions(+), 18 deletions(-)\n\n-- \n2.51.2\n\n"},{"id":"537733","messageId":"20260303204029.52952-2-r.siddharth.shrimali@gmail.com","threadId":"65130","inReplyTo":"20260303204029.52952-1-r.siddharth.shrimali@gmail.com","subject":"[PATCH v3 1/2] t3700: avoid suppressing git's exit code","fromName":"Siddharth Shrimali","fromEmail":"r.siddharth.shrimali@gmail.com","sentAt":"2026-03-03T20:40:28Z","receivedAt":"2026-03-03T20:43:01Z","isPatch":true,"sender":{"key":"r.siddharth.shrimali@gmail.com","avatar":"https://avatars.githubusercontent.com/u/183274193?v=4"},"body":"Replace pipelines involving git commands with temporary files (actual)\nto ensure that any crashes or unexpected exit codes from the git\ncommands are properly caught by the test suite. A simple pipeline\nlike 'git foo | grep bar' ignores the exit code of 'git', which\ncan hide regressions.\n\nIn cases where we were counting lines with 'wc -l' to ensure a\npattern was absent, simplify the logic to use '! grep' to avoid\nsubshells entirely.\n\nSuggested-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Siddharth Shrimali <r.siddharth.shrimali@gmail.com>\n---\n t/t3700-add.sh | 43 ++++++++++++++++++++++++++++---------------\n 1 file changed, 28 insertions(+), 15 deletions(-)\n\ndiff --git a/t/t3700-add.sh b/t/t3700-add.sh\nindex af93e53c12..c9ce2f758c 100755\n--- a/t/t3700-add.sh\n+++ b/t/t3700-add.sh\n@@ -38,7 +38,8 @@ test_expect_success 'Test with no pathspecs' '\n '\n \n test_expect_success 'Post-check that foo is in the index' '\n-\tgit ls-files foo | grep foo\n+\tgit ls-files foo >actual &&\n+\tgrep foo actual\n '\n \n test_expect_success 'Test that \"git add -- -q\" works' '\n@@ -195,8 +196,9 @@ test_expect_success 'git add with filemode=0, symlinks=0, and unmerged entries'\n \techo new > file &&\n \techo new > symlink &&\n \tgit add file symlink &&\n-\tgit ls-files --stage | grep \"^100755 .* 0\tfile$\" &&\n-\tgit ls-files --stage | grep \"^120000 .* 0\tsymlink$\"\n+\tgit ls-files --stage >actual &&\n+\tgrep \"^100755 .* 0\tfile$\" actual &&\n+\tgrep \"^120000 .* 0\tsymlink$\" actual\n '\n \n test_expect_success 'git add with filemode=0, symlinks=0 prefers stage 2 over stage 1' '\n@@ -212,8 +214,9 @@ test_expect_success 'git add with filemode=0, symlinks=0 prefers stage 2 over st\n \techo new > file &&\n \techo new > symlink &&\n \tgit add file symlink &&\n-\tgit ls-files --stage | grep \"^100755 .* 0\tfile$\" &&\n-\tgit ls-files --stage | grep \"^120000 .* 0\tsymlink$\"\n+\tgit ls-files --stage >actual &&\n+\tgrep \"^100755 .* 0\tfile$\" actual &&\n+\tgrep \"^120000 .* 0\tsymlink$\" actual\n '\n \n test_expect_success 'git add --refresh' '\n@@ -254,7 +257,8 @@ test_expect_success POSIXPERM,SANITY 'git add should fail atomically upon an unr\n \tdate >foo2 &&\n \tchmod 0 foo2 &&\n \ttest_must_fail git add --verbose . &&\n-\t! ( git ls-files foo1 | grep foo1 )\n+\tgit ls-files foo1 >actual &&\n+\t! grep foo1 actual\n '\n \n rm -f foo2\n@@ -265,7 +269,8 @@ test_expect_success POSIXPERM,SANITY 'git add --ignore-errors' '\n \tdate >foo2 &&\n \tchmod 0 foo2 &&\n \ttest_must_fail git add --verbose --ignore-errors . &&\n-\tgit ls-files foo1 | grep foo1\n+\tgit ls-files foo1 >actual &&\n+\tgrep foo1 actual\n '\n \n rm -f foo2\n@@ -277,7 +282,8 @@ test_expect_success POSIXPERM,SANITY 'git add (add.ignore-errors)' '\n \tdate >foo2 &&\n \tchmod 0 foo2 &&\n \ttest_must_fail git add --verbose . &&\n-\tgit ls-files foo1 | grep foo1\n+\tgit ls-files foo1 >actual &&\n+\tgrep foo1 actual\n '\n rm -f foo2\n \n@@ -288,7 +294,8 @@ test_expect_success POSIXPERM,SANITY 'git add (add.ignore-errors = false)' '\n \tdate >foo2 &&\n \tchmod 0 foo2 &&\n \ttest_must_fail git add --verbose . &&\n-\t! ( git ls-files foo1 | grep foo1 )\n+\tgit ls-files foo1 >actual &&\n+\t! grep foo1 actual\n '\n rm -f foo2\n \n@@ -299,7 +306,8 @@ test_expect_success POSIXPERM,SANITY '--no-ignore-errors overrides config' '\n \tdate >foo2 &&\n \tchmod 0 foo2 &&\n \ttest_must_fail git add --verbose --no-ignore-errors . &&\n-\t! ( git ls-files foo1 | grep foo1 ) &&\n+\tgit ls-files foo1 >actual &&\n+\t! grep foo1 actual &&\n \tgit config add.ignore-errors 0\n '\n rm -f foo2\n@@ -308,8 +316,10 @@ test_expect_success BSLASHPSPEC \"git add 'fo\\\\[ou\\\\]bar' ignores foobar\" '\n \tgit reset --hard &&\n \ttouch fo\\[ou\\]bar foobar &&\n \tgit add '\\''fo\\[ou\\]bar'\\'' &&\n-\tgit ls-files fo\\[ou\\]bar | grep -F fo\\[ou\\]bar &&\n-\t! ( git ls-files foobar | grep foobar )\n+\tgit ls-files fo\\[ou\\]bar >actual &&\n+\tgrep -F fo\\[ou\\]bar actual &&\n+\tgit ls-files foobar >actual &&\n+\t! grep foobar actual\n '\n \n test_expect_success 'git add to resolve conflicts on otherwise ignored path' '\n@@ -326,7 +336,8 @@ test_expect_success 'git add to resolve conflicts on otherwise ignored path' '\n \n test_expect_success '\"add non-existent\" should fail' '\n \ttest_must_fail git add non-existent &&\n-\t! (git ls-files | grep \"non-existent\")\n+\tgit ls-files >actual &&\n+\t! grep \"non-existent\" actual\n '\n \n test_expect_success 'git add -A on empty repo does not error out' '\n@@ -536,9 +547,11 @@ test_expect_success 'all statuses changed in folder if . is given' '\n \t\ttouch x y z sub/a sub/dir/b &&\n \t\tgit add -A &&\n \t\tgit add --chmod=+x . &&\n-\t\ttest $(git ls-files --stage | grep ^100644 | wc -l) -eq 0 &&\n+\t\tgit ls-files --stage >actual &&\n+\t\t! grep ^100644 actual &&\n \t\tgit add --chmod=-x . &&\n-\t\ttest $(git ls-files --stage | grep ^100755 | wc -l) -eq 0\n+\t\tgit ls-files --stage >actual &&\n+\t\t! grep ^100755 actual\n \t)\n '\n \n-- \n2.51.2\n\n"},{"id":"537734","messageId":"20260303204029.52952-3-r.siddharth.shrimali@gmail.com","threadId":"65130","inReplyTo":"20260303204029.52952-1-r.siddharth.shrimali@gmail.com","subject":"[PATCH v3 2/2] t3700: use test_grep helper for better diagnostics","fromName":"Siddharth Shrimali","fromEmail":"r.siddharth.shrimali@gmail.com","sentAt":"2026-03-03T20:40:29Z","receivedAt":"2026-03-03T20:43:08Z","isPatch":true,"sender":{"key":"r.siddharth.shrimali@gmail.com","avatar":"https://avatars.githubusercontent.com/u/183274193?v=4"},"body":"Replace 'grep' and '! grep' invocations with 'test_grep' and\n'test_grep !'. This provides better debugging output if tests fail\nin the future, as 'test_grep' will automatically print the\ncontents of the file when a check fails.\n\nWhile at it, update any remaining instances of 'grep' to 'test_grep'\nthat were missed in the previous versions to ensure that the entire\nfile is consistent with modern project style.\n\nSuggested-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Siddharth Shrimali <r.siddharth.shrimali@gmail.com>\n---\n t/t3700-add.sh | 36 ++++++++++++++++++------------------\n 1 file changed, 18 insertions(+), 18 deletions(-)\n\ndiff --git a/t/t3700-add.sh b/t/t3700-add.sh\nindex c9ce2f758c..2947bf9a6b 100755\n--- a/t/t3700-add.sh\n+++ b/t/t3700-add.sh\n@@ -39,7 +39,7 @@ test_expect_success 'Test with no pathspecs' '\n \n test_expect_success 'Post-check that foo is in the index' '\n \tgit ls-files foo >actual &&\n-\tgrep foo actual\n+\ttest_grep foo actual\n '\n \n test_expect_success 'Test that \"git add -- -q\" works' '\n@@ -141,7 +141,7 @@ test_expect_success 'error out when attempting to add ignored ones but add other\n \tgit ls-files >files &&\n \tsed -n \"/\\\\.ig/p\" <files >actual &&\n \ttest_must_be_empty actual &&\n-\tgrep a.if files\n+\ttest_grep a.if files\n '\n \n test_expect_success 'add ignored ones with -f' '\n@@ -197,8 +197,8 @@ test_expect_success 'git add with filemode=0, symlinks=0, and unmerged entries'\n \techo new > symlink &&\n \tgit add file symlink &&\n \tgit ls-files --stage >actual &&\n-\tgrep \"^100755 .* 0\tfile$\" actual &&\n-\tgrep \"^120000 .* 0\tsymlink$\" actual\n+\ttest_grep \"^100755 .* 0\tfile$\" actual &&\n+\ttest_grep \"^120000 .* 0\tsymlink$\" actual\n '\n \n test_expect_success 'git add with filemode=0, symlinks=0 prefers stage 2 over stage 1' '\n@@ -215,8 +215,8 @@ test_expect_success 'git add with filemode=0, symlinks=0 prefers stage 2 over st\n \techo new > symlink &&\n \tgit add file symlink &&\n \tgit ls-files --stage >actual &&\n-\tgrep \"^100755 .* 0\tfile$\" actual &&\n-\tgrep \"^120000 .* 0\tsymlink$\" actual\n+\ttest_grep \"^100755 .* 0\tfile$\" actual &&\n+\ttest_grep \"^120000 .* 0\tsymlink$\" actual\n '\n \n test_expect_success 'git add --refresh' '\n@@ -241,8 +241,8 @@ test_expect_success 'git add --refresh with pathspec' '\n \ttest_must_be_empty actual &&\n \n \tgit diff-files --name-only >actual &&\n-\t! grep bar actual &&\n-\tgrep baz actual\n+\ttest_grep ! bar actual &&\n+\ttest_grep baz actual\n '\n \n test_expect_success 'git add --refresh correctly reports no match error' \"\n@@ -258,7 +258,7 @@ test_expect_success POSIXPERM,SANITY 'git add should fail atomically upon an unr\n \tchmod 0 foo2 &&\n \ttest_must_fail git add --verbose . &&\n \tgit ls-files foo1 >actual &&\n-\t! grep foo1 actual\n+\ttest_grep ! foo1 actual\n '\n \n rm -f foo2\n@@ -270,7 +270,7 @@ test_expect_success POSIXPERM,SANITY 'git add --ignore-errors' '\n \tchmod 0 foo2 &&\n \ttest_must_fail git add --verbose --ignore-errors . &&\n \tgit ls-files foo1 >actual &&\n-\tgrep foo1 actual\n+\ttest_grep foo1 actual\n '\n \n rm -f foo2\n@@ -283,7 +283,7 @@ test_expect_success POSIXPERM,SANITY 'git add (add.ignore-errors)' '\n \tchmod 0 foo2 &&\n \ttest_must_fail git add --verbose . &&\n \tgit ls-files foo1 >actual &&\n-\tgrep foo1 actual\n+\ttest_grep foo1 actual\n '\n rm -f foo2\n \n@@ -295,7 +295,7 @@ test_expect_success POSIXPERM,SANITY 'git add (add.ignore-errors = false)' '\n \tchmod 0 foo2 &&\n \ttest_must_fail git add --verbose . &&\n \tgit ls-files foo1 >actual &&\n-\t! grep foo1 actual\n+\ttest_grep ! foo1 actual\n '\n rm -f foo2\n \n@@ -307,7 +307,7 @@ test_expect_success POSIXPERM,SANITY '--no-ignore-errors overrides config' '\n \tchmod 0 foo2 &&\n \ttest_must_fail git add --verbose --no-ignore-errors . &&\n \tgit ls-files foo1 >actual &&\n-\t! grep foo1 actual &&\n+\ttest_grep ! foo1 actual &&\n \tgit config add.ignore-errors 0\n '\n rm -f foo2\n@@ -317,9 +317,9 @@ test_expect_success BSLASHPSPEC \"git add 'fo\\\\[ou\\\\]bar' ignores foobar\" '\n \ttouch fo\\[ou\\]bar foobar &&\n \tgit add '\\''fo\\[ou\\]bar'\\'' &&\n \tgit ls-files fo\\[ou\\]bar >actual &&\n-\tgrep -F fo\\[ou\\]bar actual &&\n+\ttest_grep -F fo\\[ou\\]bar actual &&\n \tgit ls-files foobar >actual &&\n-\t! grep foobar actual\n+\ttest_grep ! foobar actual\n '\n \n test_expect_success 'git add to resolve conflicts on otherwise ignored path' '\n@@ -337,7 +337,7 @@ test_expect_success 'git add to resolve conflicts on otherwise ignored path' '\n test_expect_success '\"add non-existent\" should fail' '\n \ttest_must_fail git add non-existent &&\n \tgit ls-files >actual &&\n-\t! grep \"non-existent\" actual\n+\ttest_grep ! \"non-existent\" actual\n '\n \n test_expect_success 'git add -A on empty repo does not error out' '\n@@ -548,10 +548,10 @@ test_expect_success 'all statuses changed in folder if . is given' '\n \t\tgit add -A &&\n \t\tgit add --chmod=+x . &&\n \t\tgit ls-files --stage >actual &&\n-\t\t! grep ^100644 actual &&\n+\t\ttest_grep ! ^100644 actual &&\n \t\tgit add --chmod=-x . &&\n \t\tgit ls-files --stage >actual &&\n-\t\t! grep ^100755 actual\n+\t\ttest_grep ! ^100755 actual\n \t)\n '\n \n-- \n2.51.2\n\n"}]}