public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Tian Yuchen <a3205153416@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH v1] t2203: avoid masking exit codes in git status
Date: Sat, 17 Jan 2026 10:15:41 -0800	[thread overview]
Message-ID: <xmqqy0lw5cmq.fsf@gitster.g> (raw)
In-Reply-To: <20260117175847.334666-1-a3205153416@gmail.com> (Tian Yuchen's message of "Sun, 18 Jan 2026 01:58:47 +0800")

Tian Yuchen <a3205153416@gmail.com> writes:

>  test_expect_success 'git status' '
> -	git status --porcelain | grep -v actual >actual &&
> +	git status --porcelain >tmp &&
> +	grep -v -e actual -e tmp tmp >actual &&

Looking at other parts of this patch makes me wonder if we can get
away by filtering lines that match "^?" out, instead of explicitly
naming 'actual' and 'tmp'.  It seems that the entire t2203 file does
not care about untraacked files at all (in other words, there is no
"expect" file that expects a line with '^?' in it), so rewriting the
above (and everything that this patch touches) to use something like

	git status --porcelain -uno >actual

makes the intent clear (i.e., we do not care about untracked files)
and simpler (i.e., we do not need "grep -v" to filter), wouldn't it?

>  	cat >expect <<-\EOF &&
>  	DA 1.t
>  	A  elif
> @@ -26,7 +27,8 @@ test_expect_success 'git status' '
>  '
>  
>  test_expect_success 'git status with porcelain v2' '
> -	git status --porcelain=v2 | grep -v "^?" >actual &&
> +	git status --porcelain=v2 >tmp &&
> +	grep -v "^?" tmp >actual &&
>  	nam1=$(echo 1 | git hash-object --stdin) &&
>  	nam2=$(git hash-object elif) &&
>  	cat >expect <<-EOF &&
> @@ -171,17 +173,20 @@ test_expect_success 'rename detection finds the right names' '
>  		mv first third &&
>  		git add -N third &&
>  
> -		git status | grep -v "^?" >actual.1 &&
> +		git status >tmp &&
> +		grep -v "^?" tmp >actual.1 &&
>  		test_grep "renamed: *first -> third" actual.1 &&
>  
> -		git status --porcelain | grep -v "^?" >actual.2 &&
> +		git status --porcelain >tmp &&
> +		grep -v "^?" tmp >actual.2 &&
>  		cat >expected.2 <<-\EOF &&
>  		 R first -> third
>  		EOF
>  		test_cmp expected.2 actual.2 &&
>  
>  		hash=$(git hash-object third) &&
> -		git status --porcelain=v2 | grep -v "^?" >actual.3 &&
> +		git status --porcelain=v2 >tmp &&
> +		grep -v "^?" tmp >actual.3 &&
>  		cat >expected.3 <<-EOF &&
>  		2 .R N... 100644 100644 100644 $hash $hash R100 third	first
>  		EOF
> @@ -211,11 +216,13 @@ test_expect_success 'double rename detection in status' '
>  		mv second third &&
>  		git add -N third &&
>  
> -		git status | grep -v "^?" >actual.1 &&
> +		git status >tmp &&
> +		grep -v "^?" tmp >actual.1 &&
>  		test_grep "renamed: *first -> second" actual.1 &&
>  		test_grep "renamed: *second -> third" actual.1 &&
>  
> -		git status --porcelain | grep -v "^?" >actual.2 &&
> +		git status --porcelain >tmp &&
> +		grep -v "^?" tmp >actual.2 &&
>  		cat >expected.2 <<-\EOF &&
>  		R  first -> second
>  		 R second -> third
> @@ -223,7 +230,8 @@ test_expect_success 'double rename detection in status' '
>  		test_cmp expected.2 actual.2 &&
>  
>  		hash=$(git hash-object third) &&
> -		git status --porcelain=v2 | grep -v "^?" >actual.3 &&
> +		git status --porcelain=v2 >tmp &&
> +		grep -v "^?" tmp >actual.3 &&
>  		cat >expected.3 <<-EOF &&
>  		2 R. N... 100644 100644 100644 $hash $hash R100 second	first
>  		2 .R N... 100644 100644 100644 $hash $hash R100 third	second
>
> base-commit: 7264e61d87e58b9d0f5e6424c47c11e9657dfb75

  reply	other threads:[~2026-01-17 18:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-17 17:58 [PATCH v1] t2203: avoid masking exit codes in git status Tian Yuchen
2026-01-17 18:15 ` Junio C Hamano [this message]
2026-01-18  4:16   ` Yushin Tian
2026-01-18  4:35 ` [PATCH GSoC v2] " Tian Yuchen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqy0lw5cmq.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=a3205153416@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox