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

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

From
Stefan Beller <sbeller@google.com>
Date
Jan 11, 2017, 23:57 UTC
Message-ID
<CAGZ79kb30nG-TAnXuUKM+exxoh816sRogwhU-hjaL+onmFR-qQ@mail.gmail.com>
In-Reply-To
<xmqqh955mb1p.fsf@gitster.mtv.corp.google.com>
On Wed, Jan 11, 2017 at 3:28 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 17 quoted lines
> 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.
agreed.
Show 17 quoted lines
>  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}"
>         '
This one fails
error: bug in the test script: broken &&-chain:
                sq=' &&
                echo "${sq}foo${sq}"
both other occurrences of using ${sq} are defining sq outside
(one as sq=\' and the other as sq="'")
So I think we either have to keep sq out of the test,
    sq="'"
    test_expect_success title '
         echo "${sq}foo${sq}"
    '
or do the echo/printf trick inside:
    test_expect_success title '
         sq=$(echo -e "\x27") &&
         echo "${sq}foo${sq}"
    '

Eh, I just realize the '\'' works inside here-doc, too. Nevermind then, I'll resend it with just quoted sq in the here-doc then.

Thanks, Stefan

Previous: Junio C HamanoNext: Stefan Beller
Message 13 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.