git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 4/4] unpack-trees: support super-prefix option

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 11, 2017, 23:28 UTC
Message-ID
<xmqqh955mb1p.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<CAGZ79kaHDnVLQr8WLoaD5KKs7EqeW=KbkptF=iHpU5t054Xcdw@mail.gmail.com>
Stefan Beller <sbeller@google.com> writes:
>> Preparing the expected output "expect" outside test_expect_success
>> block is also old-school.  Move it inside the new test?
>
> I looked into that. What is our current stance on using single/double quotes?
Using dq around executable part, i.e.
	test_expect_success title "
		echo \"'foo'\"
	"

is a million-times more grave sin even if the test initially does not refer to any variable in its body. Somebody will eventually need to add a line that refers to a variable and either forgets to quote \$ in front or properly quotes it. The former makes the variable interpolated while the arguments to the test_expect_success is prepared (which is a bug) and the latter makes the result quite ugly, like so:

	test_expect_success title "
		sq=\' var=foo &&
		echo \"\${sq}\$value\${sq}\"
	"

Enclosing the body always in sq-pair does mean something ugly like this from the beginning once you need to use sq inside:

	test_expect_success title '
		sq='\'' &&
		echo "${sq}foo${sq}"
	'
or
	test_expect_success title '
		echo "'\''foo'\''"
	'

but the ugliness is localized to places where single quote is absolutely needed, and '\'' is something eyes soon get used to as an idiom [*1*]. It does not affect every reference of variables like enclosing with dq does.

[Footnote]
*1* That "idiom"-ness is the reason why the last example above is
    not written like this:
	test_expect_success title '
		echo "'\'foo\''"
	'
    even though the sq pair surrounding "foo" is not technically
    necessary.  It lets us think of the string as almost always is
    inside sq context, with the single exception that we step
    outside sq context and append a sq by saying bs-sq (\').
Previous: Stefan BellerNext: Stefan Beller
Message 12 of 17 in “working tree operations: support superprefix”
  1. 0/4 working tree operations: support superprefixStefan Beller, Jan 10, 2017
  2. 1/4 read-tree: use OPT_BOOL instead of OPT_SET_INTStefan Beller, Jan 10, 2017
  3. Junio C HamanoJan 10, 2017
  4. 3/4 t1001: modernize styleStefan Beller, Jan 10, 2017
  5. 2/4 t1000: modernize styleStefan Beller, Jan 10, 2017
  6. Junio C HamanoJan 10, 2017
  7. Stefan BellerJan 10, 2017
  8. Junio C HamanoJan 10, 2017
  9. 4/4 unpack-trees: support super-prefix optionStefan Beller, Jan 10, 2017
  10. Junio C HamanoJan 11, 2017
  11. Stefan BellerJan 11, 2017
  12. Junio C HamanoJan 11, 2017
  13. Stefan BellerJan 11, 2017
  14. 4/4 unpack-trees: support super-prefix optionStefan Beller, Jan 12, 2017
  15. Junio C HamanoJan 12, 2017
  16. Stefan BellerJan 12, 2017
  17. Brian J. DavisJan 13, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.