Re: [Outreachy][PATCH v4] t6050: avoid pipes with upstream Git commands
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- Oct 12, 2024, 05:35 UTC
- Message-ID
- <CAPig+cSRJXoZfXdBmWt8md78t-6c2NBjeR=PK=RaKqLoCjxXMw@mail.gmail.com>
- In-Reply-To
- <20241011235959.596136-1-chizobajames21@gmail.com>
On Fri, Oct 11, 2024 at 8:00 PM <chizobajames21@gmail.com> wrote:
Show 16 quoted lines
> In pipes, the exit code of a chain of commands is determined by > the final command. In order not to miss the exit code of a failed > Git command, avoid pipes instead write output of Git commands > into a file. > For better debugging experience, instances of "grep" were changed > to "test_grep". "test_grep" provides more context in case of a > failed "grep". > > Signed-off-by: Chizoba ODINAKA <chizobajames21@gmail.com> > --- > diff --git a/t/t6050-replace.sh b/t/t6050-replace.sh > @@ -344,7 +374,8 @@ test_expect_success 'test --format medium' ' > - git replace -l --format medium | sort >actual && > + git replace -l --format medium >actual && > + sort actual -o actual && > test_cmp expected actual
Although `sort -o` is POSIX, it may not be supported by all platforms on which Git is built. Moreover, as far as I can tell, `sort -o` is not used at all in the Git test suite, so we should be wary of using it here. Therefore, rather than introducing a novel use of this command, which might possibly break on some platform, instead stick with what is known to work without problem:
git replace -l --format medium >output &&
sort output >actual &&