From: Junio C Hamano <gitster@pobox.com>
To: Eric Sunshine <sunshine@sunshineco.com>
Cc: ayu-ch <ayu.chandekar@gmail.com>, git@vger.kernel.org
Subject: Re: [PATCH] t6423: fix suppression of Git’s exit code in tests
Date: Sun, 02 Feb 2025 16:04:30 -0800 [thread overview]
Message-ID: <xmqq34gv3nch.fsf@gitster.g> (raw)
In-Reply-To: <CAPig+cSBi05Kq1ohxQJ8BwTsis++fAAaVCd8Ep8k=8cLS74jsw@mail.gmail.com> (Eric Sunshine's message of "Sun, 2 Feb 2025 08:35:45 -0500")
Eric Sunshine <sunshine@sunshineco.com> writes:
> I was curious if the project has a preference between `uniq filename`
> and `uniq <filename`, but apparently we haven't:
>
> % git grep 'uniq <' -- t | wc -l
> 2
> git grep 'uniq [a-z0-9]' -- t | wc -l
> 2
>
> Though there does seem to be a global preference in the project to
> specify the filename directly to the command rather than redirecting
> from stdin. For instance:
>
> % git grep 'sort <' -- t | wc -l
> 54
> % git grep 'sort [a-z0-9]' -- t | wc -l
> 140
Have you inspected the hits from these grep runs?
$ git grep -c 'sort [a-z0-9]' -- t/t7004-tag.sh
t/t7004-tag.sh:17
Among 17 of them, 15 are on test titles.
$ git grep -c '^test_expect_[sf].*sort [a-z0-9]' -- t/t7004-tag.sh
t/t7004-tag.sh:15
So the above numbers are totally unreliable as a guide, I am afraid.
It is probably better to use sort/uniq without input redirection
because your
$ sort/uniq input >output
can be easily extended to
$ sort/uniq input-a input-b input-c >output
but
$ sort/uniq <input >output
cannot be extended the same way, and you'd end up doing nonsense
pipe like this:
$ cat input-a input-b input-c | sort >output
which is a no-no.
In reality, however, we are not all that logical.
$ git grep -e '^[ ]*sort [a-z0-9][-a-z0-9]* ' -- t | wc -l
46
$ git grep -e '^[ ]*sort <' -- t | wc -l
51
with "s/sort/uniq/", the numbers are 0 vs 1.
There are a handful of sort invocations that take their input from
redirected <<HEREDOC included in the latter number, but the overall
picture does not change with them excluded.
next prev parent reply other threads:[~2025-02-03 0:04 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-02 12:09 [PATCH] t6423: fix suppression of Git’s exit code in tests ayu-ch
2025-02-02 13:18 ` Meet Soni
2025-02-02 13:35 ` Eric Sunshine
2025-02-03 0:04 ` Junio C Hamano [this message]
2025-02-04 0:38 ` Ayush Chandekar
2025-02-04 13:08 ` Junio C Hamano
2025-02-05 14:28 ` [GSOC][PATCH v2] t6422: avoid suppressing " Ayush Chandekar
2025-02-05 20:47 ` Junio C Hamano
2025-02-06 5:08 ` [GSOC][PATCH v2] t6423: " Ayush Chandekar
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=xmqq34gv3nch.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=ayu.chandekar@gmail.com \
--cc=git@vger.kernel.org \
--cc=sunshine@sunshineco.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.