git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Taylor Blau <me@ttaylorr.com>
To: Beat Bolli <dev+git@drbeat.li>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH v2 16/22] t/t3*: merge a "grep | awk" pipeline
Date: Sat, 16 Mar 2024 11:46:56 -0400	[thread overview]
Message-ID: <ZfW+8GTKlxq1S1Tx@nand.local> (raw)
In-Reply-To: <5aacb015-c01a-4c6f-8e37-931581aa71b6@drbeat.li>

On Sat, Mar 16, 2024 at 11:09:47AM +0100, Beat Bolli wrote:
> On 16.03.24 02:49, Taylor Blau wrote:
> > On Fri, Mar 15, 2024 at 08:46:13PM +0100, Beat Bolli wrote:
> > > Signed-off-by: Beat Bolli <dev+git@drbeat.li>
> > > ---
> > >   t/t3920-crlf-messages.sh | 2 +-
> > >   1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/t/t3920-crlf-messages.sh b/t/t3920-crlf-messages.sh
> > > index 5eed640a6825..50ae222f0842 100755
> > > --- a/t/t3920-crlf-messages.sh
> > > +++ b/t/t3920-crlf-messages.sh
> > > @@ -97,7 +97,7 @@ test_expect_success 'branch: --verbose works with messages using CRLF' '
> > >   	git branch -v >tmp &&
> > >   	# Remove first two columns, and the line for the currently checked out branch
> > >   	current=$(git branch --show-current) &&
> > > -	grep -v $current <tmp | awk "{\$1=\$2=\"\"}1"  >actual &&
> > > +	awk "/$current/ { next } { \$1 = \$2 = \"\" } 1" <tmp >actual &&
> >
> > I think that using `next` here is fine to ignore lines that match
> > `$current`, but the canonical approach would probably be using the
> > `!` operator instead to negate the match, like so:
> >
> >      awk "!/$current/ { \$1 = \$2 = \"\" } 1" <tmp >actual &&
> >
> > Not worth a reroll, of course, just something that I noticed while
> > reading.
>
> Except it's not the same :-) This was actually my first try, but then I
> realized that awk continues to evaluate patterns and actions until the end
> of the script. The "1" at the end is the "always true" pattern that causes
> the default action "print $0" to run.
>
> So the "next" is needed to discard the current line.
>
> Having said this,
>
>     awk "!/$current/ { \$1 = \$2 = \"\"; print \$0 }" <tmp >actual &&
>
> would work, and it would also remove the obscure flow detailed above.
>

Ah. Thanks for the explanation. These details would not hurt to have in
a commit message, but I think that this change is fine as-is. Those
curious enough can likely find this thread on the list for this
particular instance.

But these sort of less-than-trivial details are exactly the sorts of
things we like to capture in a well-written patch message.

Thanks,
Taylor


  reply	other threads:[~2024-03-16 15:47 UTC|newest]

Thread overview: 78+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-05 21:24 [PATCH 00/22] avoid redundant pipelines Beat Bolli
2024-03-05 21:25 ` [PATCH 01/22] doc: avoid redundant use of cat Beat Bolli
2024-03-05 22:24   ` Junio C Hamano
2024-03-05 21:25 ` [PATCH 02/22] contrib/subtree/t: " Beat Bolli
2024-03-05 22:25   ` Junio C Hamano
2024-03-05 21:25 ` [PATCH 03/22] t/lib-cvs.sh: " Beat Bolli
2024-03-05 22:26   ` Junio C Hamano
2024-03-05 21:25 ` [PATCH 04/22] t/annotate-tests.sh: " Beat Bolli
2024-03-05 22:28   ` Junio C Hamano
2024-03-06  0:04     ` Rubén Justo
2024-03-06  0:26       ` Junio C Hamano
2024-03-06  0:38         ` Rubén Justo
2024-03-05 21:25 ` [PATCH 05/22] t/perf: " Beat Bolli
2024-03-05 22:29   ` Junio C Hamano
2024-03-05 21:25 ` [PATCH 06/22] t/t0*: avoid redundant uses " Beat Bolli
2024-03-05 21:25 ` [PATCH 07/22] t/t1*: " Beat Bolli
2024-03-05 21:25 ` [PATCH 08/22] t/t3*: " Beat Bolli
2024-03-05 21:25 ` [PATCH 09/22] t/t4*: " Beat Bolli
2024-03-06  0:49   ` Junio C Hamano
2024-03-06  1:08   ` Eric Sunshine
2024-03-06 20:58     ` Beat Bolli
2024-03-05 21:25 ` [PATCH 10/22] t/t5*: " Beat Bolli
2024-03-05 21:25 ` [PATCH 11/22] t/t6*: " Beat Bolli
2024-03-05 21:25 ` [PATCH 12/22] t/t7*: avoid redundant use " Beat Bolli
2024-03-05 21:25 ` [PATCH 13/22] t/t8*: " Beat Bolli
2024-03-05 21:25 ` [PATCH 14/22] t/t9*: avoid redundant uses " Beat Bolli
2024-03-05 22:52   ` Rubén Justo
2024-03-06  0:43     ` Junio C Hamano
2024-03-06  1:10       ` Rubén Justo
2024-03-05 21:25 ` [PATCH 15/22] t/t1*: merge a "grep | sed" pipeline Beat Bolli
2024-03-05 21:25 ` [PATCH 16/22] t/t3*: merge a "grep | awk" pipeline Beat Bolli
2024-03-06  0:55   ` Junio C Hamano
2024-03-05 21:25 ` [PATCH 17/22] t/t4*: merge a "grep | sed" pipeline Beat Bolli
2024-03-05 21:25 ` [PATCH 18/22] t/t5*: " Beat Bolli
2024-03-06  0:57   ` Junio C Hamano
2024-03-05 21:25 ` [PATCH 19/22] t/t8*: merge "grep | sed" pipelines Beat Bolli
2024-03-06  0:59   ` Junio C Hamano
2024-03-06  2:17     ` Todd Zullinger
2024-03-06 16:03       ` Junio C Hamano
2024-03-06 21:03       ` Beat Bolli
2024-03-06 21:47         ` Junio C Hamano
2024-03-05 21:25 ` [PATCH 20/22] t/t9*: " Beat Bolli
2024-03-06  1:00   ` Junio C Hamano
2024-03-05 21:25 ` [PATCH 21/22] contrib/coverage-diff: avoid redundant pipelines Beat Bolli
2024-03-05 21:25 ` [PATCH 22/22] git-quiltimport: avoid an unnecessary subshell Beat Bolli
2024-03-05 22:55   ` Rubén Justo
2024-03-05 22:58 ` [PATCH 00/22] avoid redundant pipelines Rubén Justo
2024-03-05 23:51 ` Junio C Hamano
2024-03-15 19:45 ` [PATCH v2 " Beat Bolli
2024-03-15 19:45   ` [PATCH v2 01/22] doc: avoid redundant use of cat Beat Bolli
2024-03-15 19:45   ` [PATCH v2 02/22] contrib/subtree/t: " Beat Bolli
2024-03-15 19:46   ` [PATCH v2 03/22] t/lib-cvs.sh: " Beat Bolli
2024-03-15 19:46   ` [PATCH v2 04/22] t/annotate-tests.sh: " Beat Bolli
2024-03-15 19:46   ` [PATCH v2 05/22] t/perf: " Beat Bolli
2024-03-15 19:46   ` [PATCH v2 06/22] t/t0*: avoid redundant uses " Beat Bolli
2024-03-15 19:46   ` [PATCH v2 07/22] t/t1*: " Beat Bolli
2024-03-15 19:46   ` [PATCH v2 08/22] t/t3*: " Beat Bolli
2024-03-15 19:46   ` [PATCH v2 09/22] t/t4*: " Beat Bolli
2024-03-16  1:34     ` Taylor Blau
2024-03-16  6:04       ` Junio C Hamano
2024-03-15 19:46   ` [PATCH v2 10/22] t/t5*: " Beat Bolli
2024-03-15 19:46   ` [PATCH v2 11/22] t/t6*: " Beat Bolli
2024-03-15 19:46   ` [PATCH v2 12/22] t/t7*: avoid redundant use " Beat Bolli
2024-03-15 19:46   ` [PATCH v2 13/22] t/t8*: " Beat Bolli
2024-03-15 19:46   ` [PATCH v2 14/22] t/t9*: avoid redundant uses " Beat Bolli
2024-03-15 19:46   ` [PATCH v2 15/22] t/t1*: merge a "grep | sed" pipeline Beat Bolli
2024-03-15 19:46   ` [PATCH v2 16/22] t/t3*: merge a "grep | awk" pipeline Beat Bolli
2024-03-16  1:49     ` Taylor Blau
2024-03-16 10:09       ` Beat Bolli
2024-03-16 15:46         ` Taylor Blau [this message]
2024-03-15 19:46   ` [PATCH v2 17/22] t/t4*: merge a "grep | sed" pipeline Beat Bolli
2024-03-15 19:46   ` [PATCH v2 18/22] t/t5*: " Beat Bolli
2024-03-15 19:46   ` [PATCH v2 19/22] t/t8*: merge "grep | sed" pipelines Beat Bolli
2024-03-15 19:46   ` [PATCH v2 20/22] t/t9*: " Beat Bolli
2024-03-15 19:46   ` [PATCH v2 21/22] contrib/coverage-diff: avoid redundant pipelines Beat Bolli
2024-03-15 19:46   ` [PATCH v2 22/22] git-quiltimport: avoid an unnecessary subshell Beat Bolli
2024-03-16  1:51   ` [PATCH v2 00/22] avoid redundant pipelines Taylor Blau
2024-03-16 18:06     ` Junio C Hamano

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=ZfW+8GTKlxq1S1Tx@nand.local \
    --to=me@ttaylorr.com \
    --cc=dev+git@drbeat.li \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).