Volume XXII, number 280Wednesday, October 7, 2026Latest message 55 minutes ago

The Git List

News and archive of git@vger.kernel.org, since April 2005

patch, 16 partsMicroproject: avoid suppressing git's exit code

24 messages between Mar 28, 2026 and Mar 30, 2026, from Trieu Huynh, Junio C Hamano, Tian Yuchen, Karthik Nayak.

Plain Markdown or JSON for tools and agents. Diffs are folded; open one to read it.

Trieu HuynhMar 28, 2026, 20:02 UTC on lore

Piping git command output directly to subsequent command (eg. grep) hides the exit code of git behind the pipe. A crash in git would go unnoticed because the shell only sees grep's exit code.

This series extends the same fix to 16 more test files, following the approach introduced in t8003 [1] (redirect output to a temporary file, then use test_grep on that file).

Note: t2206 is a special case -- some tests cd into a subdirectory
that is itself a git repo and run 'git add .' on the whole working
tree.  To prevent the temporary file from being accidentally staged,
it is written as '../actual', outside the inner repo.
Related-to: https://lore.kernel.org/git/20260328132955.172262-1-vikingtc4@gmail.com/T/#t
See-also: https://lore.kernel.org/git/xmqq4im2sjnu.fsf@gitster.g/T/#t
Trieu Huynh (16):
  t7004: avoid suppressing git's exit code
  t6423: avoid suppressing git's exit code
  t6411: avoid suppressing git's exit code
  t6101: avoid suppressing git's exit code
  t6006: avoid suppressing git's exit code
  t5304: avoid suppressing git's exit code
  t4153: avoid suppressing git's exit code
  t4150: avoid suppressing git's exit code
  t4140: avoid suppressing git's exit code
  t4039: avoid suppressing git's exit code
  t3903: avoid suppressing git's exit code
  t3701: avoid suppressing git's exit code
  t3412: avoid suppressing git's exit code
  t1400: avoid suppressing git's exit code
  t0100: avoid suppressing git's exit code
  t2206: avoid suppressing git's exit code
 t/t0100-previous.sh                 |  3 +-
 t/t1400-update-ref.sh               |  3 +-
 t/t2206-add-submodule-ignored.sh    | 45 +++++++++++++++++++----------
 t/t3412-rebase-root.sh              |  6 ++--
 t/t3701-add-interactive.sh          | 12 +++++---
 t/t3903-stash.sh                    |  5 ++--
 t/t4039-diff-assume-unchanged.sh    |  3 +-
 t/t4140-apply-ita.sh                |  3 +-
 t/t4150-am.sh                       |  5 ++--
 t/t4153-am-resume-override-opts.sh  |  3 +-
 t/t5304-prune.sh                    |  3 +-
 t/t6006-rev-list-format.sh          |  3 +-
 t/t6101-rev-parse-parents.sh        |  3 +-
 t/t6411-merge-filemode.sh           |  6 ++--
 t/t6423-merge-rename-directories.sh |  3 +-
 t/t7004-tag.sh                      |  6 ++--
 16 files changed, 74 insertions(+), 38 deletions(-)
-- 
2.43.0
Trieu HuynhMar 28, 2026, 20:02 UTC in reply to Trieu Huynh on lore

[GSoC PATCH 01/16] t7004: avoid suppressing git's exit code

Update t7004-tag.sh to redirect git-cmds output to a temporary file instead of piping it directly to not hide the exit code of git commands behind pipes, as a crash in git might go unnoticed.

Signed-off-by: Trieu Huynh <vikingtc4@gmail.com>
---
 t/t7004-tag.sh | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
Show changes to t/t7004-tag.sh +4 −2
diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh
index ce2ff2a28a..9bd5c98f93 100755
--- a/t/t7004-tag.sh
+++ b/t/t7004-tag.sh
@@ -1560,7 +1560,8 @@ test_expect_success 'filename for the message is relative to cwd' '
 		cd subdir &&
 		git tag -a -F msgfile-5 tag-from-subdir
 	) &&
-	git cat-file tag tag-from-subdir | grep "in sub directory"
+	git cat-file tag tag-from-subdir >actual &&
+	test_grep "in sub directory" actual
 '
 
 test_expect_success 'filename for the message is relative to cwd' '
@@ -1569,7 +1570,8 @@ test_expect_success 'filename for the message is relative to cwd' '
 		cd subdir &&
 		git tag -a -F msgfile-6 tag-from-subdir-2
 	) &&
-	git cat-file tag tag-from-subdir-2 | grep "in sub directory"
+	git cat-file tag tag-from-subdir-2 >actual &&
+	test_grep "in sub directory" actual
 '
 
 # create a few more commits to test --contains
-- 
2.43.0
Trieu HuynhMar 28, 2026, 20:02 UTC in reply to Trieu Huynh on lore

[GSoC PATCH 02/16] t6423: avoid suppressing git's exit code

Update t6423-merge-rename-directories.sh to redirect git-cmds output to a temporary file instead of piping it directly to not hide the exit code of git commands behind pipes, as a crash in git might go unnoticed.

Signed-off-by: Trieu Huynh <vikingtc4@gmail.com>
---
 t/t6423-merge-rename-directories.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Show changes to t/t6423-merge-rename-directories.sh +2 −1
diff --git a/t/t6423-merge-rename-directories.sh b/t/t6423-merge-rename-directories.sh
index 53535a8ebf..52665cedcd 100755
--- a/t/t6423-merge-rename-directories.sh
+++ b/t/t6423-merge-rename-directories.sh
@@ -2273,7 +2273,8 @@ test_expect_success '8c: modify/delete or rename+modify/delete' '
 		test_cmp expect actual &&
 
 		test_must_fail git rev-parse :2:z/d &&
-		git ls-files -s z/d | grep ^100755 &&
+		git ls-files -s z/d >actual &&
+		test_grep "^100755" actual &&
 		test_path_is_file z/d &&
 		test_path_is_missing y/d
 	)
-- 
2.43.0
Trieu HuynhMar 28, 2026, 20:02 UTC in reply to Trieu Huynh on lore

[GSoC PATCH 03/16] t6411: avoid suppressing git's exit code

Update t6411-merge-filemode.sh to redirect git-cmds output to a temporary file instead of piping it directly to not hide the exit code of git commands behind pipes, as a crash in git might go unnoticed.

Signed-off-by: Trieu Huynh <vikingtc4@gmail.com>
---
 t/t6411-merge-filemode.sh | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
Show changes to t/t6411-merge-filemode.sh +4 −2
diff --git a/t/t6411-merge-filemode.sh b/t/t6411-merge-filemode.sh
index 6ae2489286..9fe4271555 100755
--- a/t/t6411-merge-filemode.sh
+++ b/t/t6411-merge-filemode.sh
@@ -27,7 +27,8 @@ do_one_mode () {
 	test_expect_success "resolve single mode change ($strategy, $us)" '
 		git checkout -f $us &&
 		git merge -s $strategy $them &&
-		git ls-files -s file1 | grep ^100755
+		git ls-files -s file1 >actual &&
+		test_grep "^100755" actual
 	'
 
 	test_expect_success FILEMODE "verify executable bit on file ($strategy, $us)" '
@@ -65,7 +66,8 @@ do_both_modes () {
 		test_must_fail git merge -s $strategy b2 &&
 		git ls-files -u >actual &&
 		test_cmp expect actual &&
-		git ls-files -s file2 | grep ^100755
+		git ls-files -s file2 >actual &&
+		test_grep "^100755" actual
 	'
 
 	test_expect_success FILEMODE "verify executable bit on file ($strategy)" '
-- 
2.43.0
Trieu HuynhMar 28, 2026, 20:02 UTC in reply to Trieu Huynh on lore

[GSoC PATCH 04/16] t6101: avoid suppressing git's exit code

Update t6101-rev-parse-parents.sh to redirect git-cmds output to a temporary file instead of piping it directly to not hide the exit code of git commands behind pipes, as a crash in git might go unnoticed.

Signed-off-by: Trieu Huynh <vikingtc4@gmail.com>
---
 t/t6101-rev-parse-parents.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Show changes to t/t6101-rev-parse-parents.sh +2 −1
diff --git a/t/t6101-rev-parse-parents.sh b/t/t6101-rev-parse-parents.sh
index 5f55ab98d3..7281889717 100755
--- a/t/t6101-rev-parse-parents.sh
+++ b/t/t6101-rev-parse-parents.sh
@@ -39,7 +39,8 @@ test_expect_success 'setup' '
 '
 
 test_expect_success 'start is valid' '
-	git rev-parse start | grep "^$OID_REGEX$"
+	git rev-parse start >actual &&
+	test_grep "^$OID_REGEX$" actual
 '
 
 test_expect_success 'start^0' '
-- 
2.43.0
Trieu HuynhMar 28, 2026, 20:02 UTC in reply to Trieu Huynh on lore

[GSoC PATCH 05/16] t6006: avoid suppressing git's exit code

Update t6006-rev-list-format.sh to redirect git-cmds output to a temporary file instead of piping it directly to not hide the exit code of git commands behind pipes, as a crash in git might go unnoticed.

Signed-off-by: Trieu Huynh <vikingtc4@gmail.com>
---
 t/t6006-rev-list-format.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Show changes to t/t6006-rev-list-format.sh +2 −1
diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index 581984467d..8eaed7c502 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -289,7 +289,8 @@ test_expect_success 'basic colors' '
 '
 
 test_expect_success '%S is not a placeholder for rev-list yet' '
-	git rev-list --format="%S" -1 main | grep "%S"
+	git rev-list --format="%S" -1 main >actual &&
+	test_grep "%S" actual
 '
 
 test_expect_success 'advanced colors' '
-- 
2.43.0
Trieu HuynhMar 28, 2026, 20:02 UTC in reply to Trieu Huynh on lore

[GSoC PATCH 06/16] t5304: avoid suppressing git's exit code

Update t5304-prune.sh to redirect git-cmds output to a temporary file instead of piping it directly to not hide the exit code of git commands behind pipes, as a crash in git might go unnoticed.

Signed-off-by: Trieu Huynh <vikingtc4@gmail.com>
---
 t/t5304-prune.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Show changes to t/t5304-prune.sh +2 −1
diff --git a/t/t5304-prune.sh b/t/t5304-prune.sh
index 2be7cd30de..a6d235a8a5 100755
--- a/t/t5304-prune.sh
+++ b/t/t5304-prune.sh
@@ -264,7 +264,8 @@ test_expect_success 'prune .git/shallow when there are no loose objects' '
 	git update-ref refs/heads/shallow-tip $oid &&
 	git repack -ad &&
 	# verify assumption that all loose objects are gone
-	git count-objects | grep ^0 &&
+	git count-objects >actual &&
+	test_grep "^0" actual &&
 	git prune &&
 	echo $oid >expect &&
 	test_cmp expect .git/shallow
-- 
2.43.0
Trieu HuynhMar 28, 2026, 20:02 UTC in reply to Trieu Huynh on lore

[GSoC PATCH 07/16] t4153: avoid suppressing git's exit code

Update t4153-am-resume-override-opts.sh to redirect git-cmds output to a temporary file instead of piping it directly to not hide the exit code of git commands behind pipes, as a crash in git might go unnoticed.

Signed-off-by: Trieu Huynh <vikingtc4@gmail.com>
---
 t/t4153-am-resume-override-opts.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Show changes to t/t4153-am-resume-override-opts.sh +2 −1
diff --git a/t/t4153-am-resume-override-opts.sh b/t/t4153-am-resume-override-opts.sh
index 9bec989a0e..30137aec20 100755
--- a/t/t4153-am-resume-override-opts.sh
+++ b/t/t4153-am-resume-override-opts.sh
@@ -81,7 +81,8 @@ test_expect_success '--signoff overrides --no-signoff' '
 
 	# Applied side1 will be signed off
 	echo "Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" >expected &&
-	git cat-file commit HEAD^ | grep "Signed-off-by:" >actual &&
+	git cat-file commit HEAD^ >commit_raw &&
+	test_grep "Signed-off-by:" commit_raw >actual &&
 	test_cmp expected actual &&
 
 	# Applied side2 will not be signed off
-- 
2.43.0
Trieu HuynhMar 28, 2026, 20:02 UTC in reply to Trieu Huynh on lore

[GSoC PATCH 08/16] t4150: avoid suppressing git's exit code

Update t4150-am.sh to redirect git-cmds output to a temporary file instead of piping it directly to not hide the exit code of git commands behind pipes, as a crash in git might go unnoticed.

Signed-off-by: Trieu Huynh <vikingtc4@gmail.com>
---
 t/t4150-am.sh | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
Show changes to t/t4150-am.sh +3 −2
diff --git a/t/t4150-am.sh b/t/t4150-am.sh
index 699a81ab5c..462e450c60 100755
--- a/t/t4150-am.sh
+++ b/t/t4150-am.sh
@@ -1094,8 +1094,9 @@ test_expect_success 'am works with multi-line in-body headers' '
 	git checkout HEAD^ &&
 	git am msg &&
 	# Ensure that the author and full message are present
-	git cat-file commit HEAD | grep "^author.*long@example.com" &&
-	git cat-file commit HEAD | grep "^$LONG$"
+	git cat-file commit HEAD >actual &&
+	test_grep "^author.*long@example.com" actual &&
+	test_grep "^$LONG$" actual
 '
 
 test_expect_success 'am --quit keeps HEAD where it is' '
-- 
2.43.0
Trieu HuynhMar 28, 2026, 20:02 UTC in reply to Trieu Huynh on lore

[GSoC PATCH 09/16] t4140: avoid suppressing git's exit code

Update t4140-apply-ita.sh to redirect git-cmds output to a temporary file instead of piping it directly to not hide the exit code of git commands behind pipes, as a crash in git might go unnoticed.

Signed-off-by: Trieu Huynh <vikingtc4@gmail.com>
---
 t/t4140-apply-ita.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Show changes to t/t4140-apply-ita.sh +2 −1
diff --git a/t/t4140-apply-ita.sh b/t/t4140-apply-ita.sh
index 0b11a8aef4..15eef0a2ba 100755
--- a/t/t4140-apply-ita.sh
+++ b/t/t4140-apply-ita.sh
@@ -79,7 +79,8 @@ test_expect_success 'apply complex patch with -N' '
 	git apply -N complex-patch &&
 
 	git ls-files --stage --error-unmatch test-file &&
-	git diff | grep "a/committed-file"
+	git diff >actual &&
+	test_grep "a/committed-file" actual
 '
 
 test_done
-- 
2.43.0
Trieu HuynhMar 28, 2026, 20:02 UTC in reply to Trieu Huynh on lore

[GSoC PATCH 10/16] t4039: avoid suppressing git's exit code

Update t4039-diff-assume-unchanged.sh to redirect git-cmds output to a temporary file instead of piping it directly to not hide the exit code of git commands behind pipes, as a crash in git might go unnoticed.

Signed-off-by: Trieu Huynh <vikingtc4@gmail.com>
---
 t/t4039-diff-assume-unchanged.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Show changes to t/t4039-diff-assume-unchanged.sh +2 −1
diff --git a/t/t4039-diff-assume-unchanged.sh b/t/t4039-diff-assume-unchanged.sh
index 0eb0314a8b..9eb3c3f04d 100755
--- a/t/t4039-diff-assume-unchanged.sh
+++ b/t/t4039-diff-assume-unchanged.sh
@@ -21,7 +21,8 @@ test_expect_success 'setup' '
 '
 
 test_expect_success 'diff-index does not examine assume-unchanged entries' '
-	git diff-index HEAD^ -- one | grep -q $blob
+	git diff-index HEAD^ -- one >actual &&
+	test_grep "$blob" actual
 '
 
 test_expect_success 'diff-files does not examine assume-unchanged entries' '
-- 
2.43.0
Trieu HuynhMar 28, 2026, 20:02 UTC in reply to Trieu Huynh on lore

[GSoC PATCH 11/16] t3903: avoid suppressing git's exit code

Update t3903-stash.sh to redirect git-cmds output to a temporary file instead of piping it directly to not hide the exit code of git commands behind pipes, as a crash in git might go unnoticed.

Signed-off-by: Trieu Huynh <vikingtc4@gmail.com>
---
 t/t3903-stash.sh | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
Show changes to t/t3903-stash.sh +3 −2
diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh
index 70879941c2..b67cf23fbb 100755
--- a/t/t3903-stash.sh
+++ b/t/t3903-stash.sh
@@ -962,7 +962,8 @@ test_expect_success 'store updates stash ref and reflog' '
 	test_path_is_missing bazzy &&
 	git stash store -m quuxery $STASH_ID &&
 	test $(git rev-parse stash) = $STASH_ID &&
-	git reflog --format=%H stash| grep $STASH_ID &&
+	git reflog --format=%H stash >actual &&
+	test_grep "$STASH_ID" actual &&
 	git stash pop &&
 	grep quux bazzy
 '
@@ -976,7 +977,7 @@ test_expect_success 'handle stash specification with spaces' '
 	echo cow >file &&
 	git stash &&
 	git stash apply "stash@{$stamp}" &&
-	grep pig file
+	test_grep pig file
 '
 
 test_expect_success 'setup stash with index and worktree changes' '
-- 
2.43.0
Trieu HuynhMar 28, 2026, 20:02 UTC in reply to Trieu Huynh on lore

[GSoC PATCH 12/16] t3701: avoid suppressing git's exit code

Update t3701-add-interactive.sh to redirect git-cmds output to a temporary file instead of piping it directly to not hide the exit code of git commands behind pipes, as a crash in git might go unnoticed.

Signed-off-by: Trieu Huynh <vikingtc4@gmail.com>
---
 t/t3701-add-interactive.sh | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
Show changes to t/t3701-add-interactive.sh +8 −4
diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh
index 6e120a4001..a07db3b1aa 100755
--- a/t/t3701-add-interactive.sh
+++ b/t/t3701-add-interactive.sh
@@ -293,8 +293,10 @@ test_expect_success FILEMODE 'patch does not affect mode' '
 	echo content >>file &&
 	chmod +x file &&
 	printf "n\\ny\\n" | git add -p &&
-	git show :file | grep content &&
-	git diff file | grep "new mode"
+	git show :file >actual &&
+	test_grep content actual &&
+	git diff file >actual &&
+	test_grep "new mode" actual
 '
 
 test_expect_success FILEMODE 'stage mode but not hunk' '
@@ -302,8 +304,10 @@ test_expect_success FILEMODE 'stage mode but not hunk' '
 	echo content >>file &&
 	chmod +x file &&
 	printf "y\\nn\\n" | git add -p &&
-	git diff --cached file | grep "new mode" &&
-	git diff          file | grep "+content"
+	git diff --cached file >actual &&
+	test_grep "new mode" actual &&
+	git diff          file >actual &&
+	test_grep "+content" actual
 '
 
 
-- 
2.43.0
Trieu HuynhMar 28, 2026, 20:02 UTC in reply to Trieu Huynh on lore

[GSoC PATCH 13/16] t3412: avoid suppressing git's exit code

Update t3412-rebase-root.sh to redirect git-cmds output to a temporary file instead of piping it directly to not hide the exit code of git commands behind pipes, as a crash in git might go unnoticed.

Signed-off-by: Trieu Huynh <vikingtc4@gmail.com>
---
 t/t3412-rebase-root.sh | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
Show changes to t/t3412-rebase-root.sh +4 −2
diff --git a/t/t3412-rebase-root.sh b/t/t3412-rebase-root.sh
index 58371d8a54..f56163a73e 100755
--- a/t/t3412-rebase-root.sh
+++ b/t/t3412-rebase-root.sh
@@ -171,7 +171,8 @@ test_expect_success 'set up a conflict' '
 test_expect_success 'rebase --root with conflict (first part)' '
 	git checkout -b conflict1 other &&
 	test_must_fail git rebase --root --onto main &&
-	git ls-files -u | grep "B$"
+	git ls-files -u >actual &&
+	test_grep "B$" actual
 '
 
 test_expect_success 'fix the conflict' '
@@ -198,7 +199,8 @@ test_expect_success 'rebase --root with conflict (second part)' '
 test_expect_success 'rebase -i --root with conflict (first part)' '
 	git checkout -b conflict2 other &&
 	test_must_fail git rebase -i --root --onto main &&
-	git ls-files -u | grep "B$"
+	git ls-files -u >actual &&
+	test_grep "B$" actual
 '
 
 test_expect_success 'fix the conflict' '
-- 
2.43.0
Trieu HuynhMar 28, 2026, 20:02 UTC in reply to Trieu Huynh on lore

[GSoC PATCH 14/16] t1400: avoid suppressing git's exit code

Update t1400-update-ref.sh to redirect git-cmds output to a temporary file instead of piping it directly to not hide the exit code of git commands behind pipes, as a crash in git might go unnoticed.

Signed-off-by: Trieu Huynh <vikingtc4@gmail.com>
---
 t/t1400-update-ref.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Show changes to t/t1400-update-ref.sh +2 −1
diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh
index b2858a9061..9f34359eb0 100755
--- a/t/t1400-update-ref.sh
+++ b/t/t1400-update-ref.sh
@@ -1404,7 +1404,8 @@ test_expect_success 'handle per-worktree refs in refs/bisect' '
 		! grep refs/bisect for-each-ref.out &&
 		git update-ref refs/bisect/something HEAD &&
 		git rev-parse refs/bisect/something >../worktree-head &&
-		git for-each-ref | grep refs/bisect/something
+		git for-each-ref >actual &&
+		test_grep refs/bisect/something actual
 	) &&
 	git show-ref >actual &&
 	! grep 'refs/bisect' actual &&
-- 
2.43.0
Trieu HuynhMar 28, 2026, 20:02 UTC in reply to Trieu Huynh on lore

[GSoC PATCH 15/16] t0100: avoid suppressing git's exit code

Update t0100-previous.sh to redirect git-cmds output to a temporary file instead of piping it directly to not hide the exit code of git commands behind pipes, as a crash in git might go unnoticed.

Signed-off-by: Trieu Huynh <vikingtc4@gmail.com>
---
 t/t0100-previous.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Show changes to t/t0100-previous.sh +2 −1
diff --git a/t/t0100-previous.sh b/t/t0100-previous.sh
index dd5d9b4e5e..94a12e4ab6 100755
--- a/t/t0100-previous.sh
+++ b/t/t0100-previous.sh
@@ -40,7 +40,8 @@ test_expect_success 'merge @{-1}' '
 	git checkout other &&
 	git checkout main &&
 	git merge @{-1} &&
-	git cat-file commit HEAD | grep "Merge branch '\''other'\''"
+	git cat-file commit HEAD >actual &&
+	test_grep "Merge branch '\''other'\''" actual
 '
 
 test_expect_success 'merge @{-1}~1' '
-- 
2.43.0
Trieu HuynhMar 28, 2026, 20:02 UTC in reply to Trieu Huynh on lore

[GSoC PATCH 16/16] t2206: avoid suppressing git's exit code

Update t2206-add-submodule-ignored.sh to redirect git-cmds output to a temporary file instead of piping it directly to not hide the exit code of git commands behind pipes, as a crash in git might go unnoticed.

Some tests run inside a subdirectory that is itself a git repo and use 'git add .' on the whole working tree, so the temporary file is written as '../actual' to keep it outside the inner repo and prevent it from being accidentally staged.

Signed-off-by: Trieu Huynh <vikingtc4@gmail.com>
---
 t/t2206-add-submodule-ignored.sh | 45 +++++++++++++++++++++-----------
 1 file changed, 30 insertions(+), 15 deletions(-)
Show changes to t/t2206-add-submodule-ignored.sh +30 −15
diff --git a/t/t2206-add-submodule-ignored.sh b/t/t2206-add-submodule-ignored.sh
index e581e87ab2..7141012e50 100755
--- a/t/t2206-add-submodule-ignored.sh
+++ b/t/t2206-add-submodule-ignored.sh
@@ -45,9 +45,11 @@ test_expect_success 'main: add submodule with default config'  '
 	cd main &&
 	git submodule add ../sub &&
 	git commit -m "add submodule" &&
-	git log --oneline --name-only | grep "^sub$" &&
+	git log --oneline --name-only >actual &&
+	test_grep "^sub$" actual &&
 	git -C sub reset --hard v2.0 &&
-	git status --porcelain | grep "^ M sub$" &&
+	git status --porcelain >actual &&
+	test_grep "^ M sub$" actual &&
 	echo
 '
 #3
@@ -58,8 +60,10 @@ test_expect_success 'main: submodule config ignore=all'  '
 	git config -f .gitmodules submodule.sub.ignore all &&
 	GIT_TRACE=1 git add . &&
 	git commit -m "update submodule config sub.ignore all" &&
-	! git status --porcelain | grep "^.*$" &&
-	! git log --oneline --name-only | grep "^sub$" &&
+	git status --porcelain >../actual &&
+	test_must_be_empty ../actual &&
+	git log --oneline --name-only >../actual &&
+	test_grep ! "^sub$" ../actual &&
 	echo
 '
 #4
@@ -69,8 +73,10 @@ test_expect_success 'sub: change to different sha1 and check status in main'  '
 	cd "${base_path}" &&
 	cd main &&
 	git -C sub reset --hard v1.0 &&
-	! git status --porcelain | grep "^ M sub$" &&
-	git status --ignore-submodules=none --porcelain | grep "^ M sub$" &&
+	git status --porcelain >../actual &&
+	test_grep ! "^ M sub$" ../actual &&
+	git status --ignore-submodules=none --porcelain >../actual &&
+	test_grep "^ M sub$" ../actual &&
 	echo
 '
 
@@ -80,7 +86,8 @@ test_expect_success 'main: check normal add and status'  '
 	cd "${base_path}" &&
 	cd main &&
 	GIT_TRACE=1 git add . &&
-	! git status --porcelain | grep "^ M sub$" &&
+	git status --porcelain >../actual &&
+	test_grep ! "^ M sub$" ../actual &&
 	echo
 '
 
@@ -91,7 +98,8 @@ test_expect_success 'main: check --force add . and status'  '
 	cd "${base_path}" &&
 	cd main &&
 	GIT_TRACE=1 git add --force . &&
-	! git status --porcelain | grep "^M  sub$" &&
+	git status --porcelain >../actual &&
+	test_grep ! "^M  sub$" ../actual &&
 	echo
 '
 
@@ -101,8 +109,10 @@ test_expect_success 'main: check --force add . and status'  '
 test_expect_success 'main: check _add sub_ and status'  '
 	cd "${base_path}" &&
 	cd main &&
-	GIT_TRACE=1 git add sub 2>&1 | grep "Skipping submodule due to ignore=all: sub" &&
-	! git status --porcelain | grep "^M  sub$" &&
+	GIT_TRACE=1 git add sub >../actual 2>&1 &&
+	test_grep "Skipping submodule due to ignore=all: sub" ../actual &&
+	git status --porcelain >../actual &&
+	test_grep ! "^M  sub$" ../actual &&
 	echo
 '
 
@@ -118,15 +128,20 @@ test_expect_success 'main: check force add sub and ./sub/ and status'  '
 	cd main &&
 	echo "Adding with --force should work: git add --force sub" &&
 	GIT_TRACE=1 git add --force sub &&
-	git status --porcelain | grep "^M  sub$" &&
+	git status --porcelain >../actual &&
+	test_grep "^M  sub$" ../actual &&
 	git restore --staged sub &&
-	! git status --porcelain | grep "^M  sub$" &&
+	git status --porcelain >../actual &&
+	test_grep ! "^M  sub$" ../actual &&
 	echo "Adding with --force should work: git add --force ./sub/" &&
 	GIT_TRACE=1 git add --force ./sub/ &&
-	git status --porcelain | grep "^M  sub$" &&
+	git status --porcelain >../actual &&
+	test_grep "^M  sub$" ../actual &&
 	git commit -m "update submodule pointer" &&
-	! git status --porcelain | grep "^ M sub$" &&
-	git log --ignore-submodules=none --name-only --oneline | grep "^sub$" &&
+	git status --porcelain >../actual &&
+	test_grep ! "^ M sub$" ../actual &&
+	git log --ignore-submodules=none --name-only --oneline >../actual &&
+	test_grep "^sub$" ../actual &&
 	echo
 '
 
-- 
2.43.0
Junio C HamanoMar 29, 2026, 00:44 UTC in reply to Trieu Huynh on lore

Re: [GSoC PATCH 00/16] Microproject: avoid suppressing git's exit code

Trieu Huynh <vikingtc4@gmail.com> writes:
Show 15 quoted lines
> Piping git command output directly to subsequent command (eg. grep)
> hides the exit code of git behind the pipe.  A crash in git would go
> unnoticed because the shell only sees grep's exit code.
>
> This series extends the same fix to 16 more test files, following the
> approach introduced in t8003 [1] (redirect output to a temporary file,
> then use test_grep on that file).
>
> Note: t2206 is a special case -- some tests cd into a subdirectory
> that is itself a git repo and run 'git add .' on the whole working
> tree.  To prevent the temporary file from being accidentally staged,
> it is written as '../actual', outside the inner repo.
>
> Related-to: https://lore.kernel.org/git/20260328132955.172262-1-vikingtc4@gmail.com/T/#t
> See-also: https://lore.kernel.org/git/xmqq4im2sjnu.fsf@gitster.g/T/#t
See also https://git.github.io/General-Microproject-Information/#:~:text=Only%20ONE%20quality%20focused%20microproject%20per%20applicant
Thanks.
Trieu HuynhMar 29, 2026, 12:59 UTC in reply to Junio C Hamano on lore

Re: [GSoC PATCH 00/16] Microproject: avoid suppressing git's exit code

On Sat, Mar 28, 2026 at 05:44:48PM -0700, Junio C Hamano wrote:
Show 21 quoted lines
> Trieu Huynh <vikingtc4@gmail.com> writes:
> 
> > Piping git command output directly to subsequent command (eg. grep)
> > hides the exit code of git behind the pipe.  A crash in git would go
> > unnoticed because the shell only sees grep's exit code.
> >
> > This series extends the same fix to 16 more test files, following the
> > approach introduced in t8003 [1] (redirect output to a temporary file,
> > then use test_grep on that file).
> >
> > Note: t2206 is a special case -- some tests cd into a subdirectory
> > that is itself a git repo and run 'git add .' on the whole working
> > tree.  To prevent the temporary file from being accidentally staged,
> > it is written as '../actual', outside the inner repo.
> >
> > Related-to: https://lore.kernel.org/git/20260328132955.172262-1-vikingtc4@gmail.com/T/#t
> > See-also: https://lore.kernel.org/git/xmqq4im2sjnu.fsf@gitster.g/T/#t
> 
> See also https://git.github.io/General-Microproject-Information/#:~:text=Only%20ONE%20quality%20focused%20microproject%20per%20applicant
> 
> Thanks.

Ack, I missed that point. Could you clarify how many patches or files changed are considered appropriate for the microproject?

BRs,
Tian YuchenMar 29, 2026, 15:59 UTC in reply to Trieu Huynh on lore

Re: [GSoC PATCH 07/16] t4153: avoid suppressing git's exit code

On 3/29/26 04:02, Trieu Huynh wrote:
Show 21 quoted lines
> Update t4153-am-resume-override-opts.sh to redirect git-cmds
> output to a temporary file instead of piping it directly to
> not hide the exit code of git commands behind pipes, as a crash
> in git might go unnoticed.
> 
> Signed-off-by: Trieu Huynh <vikingtc4@gmail.com>
> ---
>   t/t4153-am-resume-override-opts.sh | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/t/t4153-am-resume-override-opts.sh b/t/t4153-am-resume-override-opts.sh
> index 9bec989a0e..30137aec20 100755
> --- a/t/t4153-am-resume-override-opts.sh
> +++ b/t/t4153-am-resume-override-opts.sh
> @@ -81,7 +81,8 @@ test_expect_success '--signoff overrides --no-signoff' '
>   
>   	# Applied side1 will be signed off
>   	echo "Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" >expected &&
> -	git cat-file commit HEAD^ | grep "Signed-off-by:" >actual &&
> +	git cat-file commit HEAD^ >commit_raw &&
> +	test_grep "Signed-off-by:" commit_raw >actual &&

The behavior of 'test_grep' is the opposite of what you might expect. It does nothing when the input matches, and only reports an error when it doesn't match. Therefore, 'actual' is empty here...

>   	test_cmp expected actual &&
>   
>   	# Applied side2 will not be signed off
...and this test is bound to fail.
Regards, Yuchen
Tian YuchenMar 29, 2026, 16:14 UTC in reply to Trieu Huynh on lore

Re: [GSoC PATCH 11/16] t3903: avoid suppressing git's exit code

On 3/29/26 04:02, Trieu Huynh wrote:
Show 30 quoted lines
> Update t3903-stash.sh to redirect git-cmds output to a temporary
> file instead of piping it directly to not hide the exit code
> of git commands behind pipes, as a crash in git might go
> unnoticed.
> 
> Signed-off-by: Trieu Huynh <vikingtc4@gmail.com>
> ---
>   t/t3903-stash.sh | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh
> index 70879941c2..b67cf23fbb 100755
> --- a/t/t3903-stash.sh
> +++ b/t/t3903-stash.sh
> @@ -962,7 +962,8 @@ test_expect_success 'store updates stash ref and reflog' '
>   	test_path_is_missing bazzy &&
>   	git stash store -m quuxery $STASH_ID &&
>   	test $(git rev-parse stash) = $STASH_ID &&
> -	git reflog --format=%H stash| grep $STASH_ID &&
> +	git reflog --format=%H stash >actual &&
> +	test_grep "$STASH_ID" actual &&
>   	git stash pop &&
>   	grep quux bazzy
>   '
> @@ -976,7 +977,7 @@ test_expect_success 'handle stash specification with spaces' '
>   	echo cow >file &&
>   	git stash &&
>   	git stash apply "stash@{$stamp}" &&
> -	grep pig file
> +	test_grep pig file

What does this have to do with the title of this patch? There is no pipe operator here, not even a single Git command. I suspect you wrote a script to generate this series of patches. The commit messages are the same for every patch.

As mentioned in the link provided by Junio, what matters in microprojects is quality, not quantity. Are these patches meaningful in and of themselves? Of course they are, but are they *necessary*? That’s a matter of opinion. What really matters is that the Git community evaluates your overall performance to determine whether you have the ability to write code according to the code guidelines, test your own work, and communicate with other developers — not how useful the patch itself is.

>   '
>   
>   test_expect_success 'setup stash with index and worktree changes' '
Keep learning, and welcome to the Git community!
Regards, Yuchen
Karthik NayakMar 30, 2026, 09:51 UTC in reply to Trieu Huynh on lore

Re: [GSoC PATCH 00/16] Microproject: avoid suppressing git's exit code

Trieu Huynh <vikingtc4@gmail.com> writes:
Show 26 quoted lines
> On Sat, Mar 28, 2026 at 05:44:48PM -0700, Junio C Hamano wrote:
>> Trieu Huynh <vikingtc4@gmail.com> writes:
>>
>> > Piping git command output directly to subsequent command (eg. grep)
>> > hides the exit code of git behind the pipe.  A crash in git would go
>> > unnoticed because the shell only sees grep's exit code.
>> >
>> > This series extends the same fix to 16 more test files, following the
>> > approach introduced in t8003 [1] (redirect output to a temporary file,
>> > then use test_grep on that file).
>> >
>> > Note: t2206 is a special case -- some tests cd into a subdirectory
>> > that is itself a git repo and run 'git add .' on the whole working
>> > tree.  To prevent the temporary file from being accidentally staged,
>> > it is written as '../actual', outside the inner repo.
>> >
>> > Related-to: https://lore.kernel.org/git/20260328132955.172262-1-vikingtc4@gmail.com/T/#t
>> > See-also: https://lore.kernel.org/git/xmqq4im2sjnu.fsf@gitster.g/T/#t
>>
>> See also https://git.github.io/General-Microproject-Information/#:~:text=Only%20ONE%20quality%20focused%20microproject%20per%20applicant
>>
>> Thanks.
> Ack, I missed that point. Could you clarify how many patches or
> files changed are considered appropriate for the microproject?
>
> BRs,
Hello,

The microprojects are meant for contributors to get a hang of contributing to the project. As such, we expect only a single file change. This is also listed in the Guidelines [1].

Thanks
[1]: https://git.github.io/General-Microproject-Information/
Junio C HamanoMar 30, 2026, 15:00 UTC in reply to Trieu Huynh on lore

Re: [GSoC PATCH 00/16] Microproject: avoid suppressing git's exit code

Trieu Huynh <vikingtc4@gmail.com> writes:
> Ack, I missed that point. Could you clarify how many patches or
> files changed are considered appropriate for the microproject?

The end product (i.e., a patch that could be applied to my tree) of a microproject is not expected to have any value to improve the project codebase. The process has two objectives. One is to help new people experience the end-to-end process of sending their first patch, getting it reviewed, engaging in a dialog with the reviewer and communicating with others in the community, and polishing and resubmitting the patch. And the other is to help us see how well each candidate can work with reviewers and others in the community.

The size of a microproject submission to allow us achieve the two goals may ideally be one-liner change ;-) but it may be a bit too hard to gauge the effectiveness of the candidate with such a small patch, so in practice the lower bound would be a single file with a few hunks, with two paragraphs in the proposed log message.

And we certainly do not need 16-patch series, each doing very similar things and likely to be making similar mistakes at the same time. Interactions with reviewers on just one patch would be sufficient for them to learn the community norm, and for us to gauge how effective the canidate is, without doing the same or similar exchanges for the other 15 patches.

Trieu HuynhMar 30, 2026, 18:50 UTC in reply to Junio C Hamano on lore

Re: [GSoC PATCH 00/16] Microproject: avoid suppressing git's exit code

On Mon, Mar 30, 2026 at 08:00:15AM -0700, Junio C Hamano wrote:
Show 27 quoted lines
> Trieu Huynh <vikingtc4@gmail.com> writes:
> 
> > Ack, I missed that point. Could you clarify how many patches or
> > files changed are considered appropriate for the microproject?
> 
> The end product (i.e., a patch that could be applied to my tree) of
> a microproject is not expected to have any value to improve the
> project codebase.  The process has two objectives.  One is to help
> new people experience the end-to-end process of sending their first
> patch, getting it reviewed, engaging in a dialog with the reviewer
> and communicating with others in the community, and polishing and
> resubmitting the patch.  And the other is to help us see how well
> each candidate can work with reviewers and others in the community.
> 
> The size of a microproject submission to allow us achieve the two
> goals may ideally be one-liner change ;-) but it may be a bit too
> hard to gauge the effectiveness of the candidate with such a small
> patch, so in practice the lower bound would be a single file with a
> few hunks, with two paragraphs in the proposed log message.
> 
> And we certainly do not need 16-patch series, each doing very
> similar things and likely to be making similar mistakes at the same
> time.  Interactions with reviewers on just one patch would be
> sufficient for them to learn the community norm, and for us to gauge
> how effective the canidate is, without doing the same or similar
> exchanges for the other 15 patches.
> 

Hello, I appreciate all your kind comments. Thank you. Drop this series here.

BRs,

Back to recent threads