git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jerry Zhang <jerry@skydio.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH V3 1/2] patch-id: Fix antipatterns in tests
Date: Tue, 01 Feb 2022 15:16:24 -0800	[thread overview]
Message-ID: <xmqqy22u9nzr.fsf@gitster.g> (raw)
In-Reply-To: <20220131235218.27392-1-jerry@skydio.com> (Jerry Zhang's message of "Mon, 31 Jan 2022 15:52:18 -0800")

Jerry Zhang <jerry@skydio.com> writes:

> Clean up the tests for patch-id by moving file preparation
> tasks inside the test body and redirecting files directly into
> stdin instead of using 'cat'.
>
> Signed-off-by: Jerry Zhang <jerry@skydio.com>
> ---
> V2->V3:
> - Quote the EOF marker


Yes but no.

>  test_expect_success 'patch-id handles no-nl-at-eof markers' '
> -	cat nonl | calc_patch_id nonl &&
> -	cat withnl | calc_patch_id withnl &&
> +	cat >nonl <<-'EOF' &&

We started the "executable" part of the test_expect_success as a
single-quoted string, and then after writing <<-, we stepped out of
that single-quote pair.  Then we are writing E O F unquoted, and
stepped back into another single-quote pair here.  So, to the shell
that runs this executable part, it is exactly the same as

	cat >nonl <<-EOF &&

side note: if it were not in a plain shell script (not the
executable part that is passed as a single string to the
test_expect_success function as an argument), what we see above,
quoting EOF within a pair of single-quotes, is perfectly acceptable
thing to do.  But not here, for the reasons explained above.

> +	diff --git i/a w/a
> +	index e69de29..2e65efe 100644
> +	--- i/a
> +	+++ w/a
> +	@@ -0,0 +1 @@
> +	+a
> +	\ No newline at end of file
> +	diff --git i/b w/b
> +	index e69de29..6178079 100644
> +	--- i/b
> +	+++ w/b
> +	@@ -0,0 +1 @@
> +	+b
> +	'EOF'

Same here.  It is exactly the same as writing EOF without any quotes
around it, just like the opening one we saw earlier.

In other words, the above is not quoting at all.

I think I demonstrated the way we should write this in my earlier
review when I pointed out this exiting issue this step is fixing
(https://lore.kernel.org/git/xmqqmtjbh5fu.fsf@gitster.g/):

	test_expect_success "title string" '
		...
		command <<-\EOF &&
		here document indented by tab
		more document
		EOF

  parent reply	other threads:[~2022-02-01 23:16 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-31 23:23 [PATCH 1/2] format-patch: Fix antipatterns in tests Jerry Zhang
2022-01-31 23:23 ` [PATCH V3 2/2] patch-id: fix scan_hunk_header on diffs with 1 line of before/after Jerry Zhang
2022-01-31 23:52   ` [PATCH V4 " Jerry Zhang
2022-02-02  4:19     ` [PATCH V5 " Jerry Zhang
2022-01-31 23:25 ` [PATCH V2 1/2] patch-id: Fix antipatterns in tests Jerry Zhang
2022-01-31 23:36   ` Junio C Hamano
2022-01-31 23:52   ` [PATCH V3 " Jerry Zhang
2022-02-01 22:07     ` Johannes Sixt
2022-02-01 23:18       ` Junio C Hamano
2022-02-01 23:16     ` Junio C Hamano [this message]
2022-02-02  4:20     ` [PATCH V4 " Jerry Zhang

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=xmqqy22u9nzr.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=jerry@skydio.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).