From: Junio C Hamano Date: Mon, 16 Nov 2026 16:07:11 GMT Subject: Re: [PATCH] t: use test_must_fail instead of NOT operator Message-ID: In-Reply-To: <20261115-t-tmf-refactor-v1-1-d7a95cdeaedd@gmail.com> Hardik Kumar writes: > Replace `!` operator with `test_must_fail` for multiple unit tests where > a git command is expected to fail. > > `test_must_fail` handles edge cases like a command killed by a signal > or a crash because of a segfault, by actually failing the test unlike > the `!` operator which would result in the test being passed as the > crash is accepted as a failure (the test is expected to fail). > > Signed-off-by: Hardik Kumar > --- > t/t5564-http-proxy.sh | 4 ++-- > t/t6030-bisect-porcelain.sh | 4 ++-- > t/t7400-submodule-basic.sh | 4 ++-- > t/t9001-send-email.sh | 2 +- > 4 files changed, 7 insertions(+), 7 deletions(-) All of them look sensible, but I am curious why you chose only these, among 14 hits in $ git grep -l '^[ ]*! git ' t/ I suspect that it is because these are ... > - ! git clone -c http.proxy=localhost/path https://example.com/repo.git 2>err && { > - ! git clone -c http.proxy=socks4://127.0.0.1/path https://example.com/repo.git 2>err && { > - ! git bisect run ./fail.sh 2>err && > - ! git bisect run ./fail.sh 2>err && ... simple cases in which the use of leading ! negation is the only issue with them, and if that is the reasoning, I think that is sensible. Contrasting these, many of the hits in t2206 (one among 14 hits in the above grep), for example, look like this: ! git status --porcelain | grep "^.*$" && which violates "do not hide exit status of git behind a pipe" rule, in addition to have a strange looking leading ! negation. Will queue.