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

Re: [PATCH v2] CodingGuidelines: explicitly allow "local" for test scripts

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
May 4, 2021, 12:27 UTC
Message-ID
<87czu6wuf3.fsf@evledraar.gmail.com>
In-Reply-To
<xmqqpmy76w31.fsf@gitster.g>
On Tue, May 04 2021, Junio C Hamano wrote:
Show 24 quoted lines
> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
>
>> Is there any portability reason to avoid "local" in the porcelains? I
>> don't have any plans for using it, but I don't see why we'd explicitly
>> forbid it.
>
> Things that are not even in POSIX are forbidden unless explicitly
> allowed.
>
> In general, he way we encouraged people to think has been "don't use
> it, it is not even in POSIX" and "even if it is in POSIX, we know
> the support by platform/implementation X is broken, so let's not use
> it".  It has been successfully helped us to stay out of portability
> troubles.
>
> There may be a few tiny cases where we said "practically everybody
> we care about has it, even though it is not in POSIX, and it makes
> our life so vastly be better" to explicitly allow some feature,
> though.
>
> And "local"?  Not absolutely essential, unless you are doing a
> library that you want to avoid stepping on users' toes.  Besides, we
> are no longer adding scripted Porcelains left and right---rather,
> people are actively rewriting them.

[You mailed me off-list with "Did I forget to say it is not even POSIX?", I had this reply to that, also applicable here]:

BEGIN QUOTE

I'm aware that it's not in POSIX. What I'm getting at is that anyone who doesn't support this must have been failing t0000-basic.sh since 01d3a526ad9 (t0000: check whether the shell supports the "local" keyword, 2017-10-26), released with v2.16.0.

And all tests of any kind since 78dc08875cd (test-lib: allow short options to be bundled, 2020-03-22), perhaps earlier, I didn't trace the full includes, but that's the first use in test-lib.sh itself. Released with v2.27.0.

From my own cross-platform testing and us not having any reports about this I very much suspect that this is one of those not-in-POSIX but in practice supported everywhere, or at least anywhere Git has been ported to.

So just saying it's OK to use unconditionally of "in t/?" should be fine, like e.g. some of the C89-plus-XYZ features.

END QUOTE

Afterwards it occurred to me that your stance on in-tree *.sh goes against e.g. brian's opinion on it expressed in reply to [1], i.e. that we might justify future new *.sh built-ins.

In any case, as noted above I really don't care much about using "local" in any *.sh built-in. I just don't think this "We do not use it in scripted Porcelains[...]" clause is needed at all.

It's effectively synonymous with saying "we still want to support git on platforms that are so broken they can't even run a single test in our test suite".

1. https://lore.kernel.org/git/patch-1.1-83266f30b67-20210417T084346Z-avarab@gmail.com/
Previous: Junio C HamanoNext: Junio C Hamano
Message 7 of 17 in “CodingGuidelines: explicitly allow "local" for test scripts”
  1. CodingGuidelines: explicitly allow "local" for test scriptsJunio C Hamano, May 3, 2021
  2. Eric SunshineMay 3, 2021
  3. Junio C HamanoMay 3, 2021
  4. CodingGuidelines: explicitly allow "local" for test scriptsJunio C Hamano, May 3, 2021
  5. Ævar Arnfjörð BjarmasonMay 3, 2021
  6. Junio C HamanoMay 4, 2021
  7. Ævar Arnfjörð BjarmasonMay 4, 2021
  8. Junio C HamanoMay 4, 2021
  9. Ævar Arnfjörð BjarmasonMay 4, 2021
  10. Felipe ContrerasMay 4, 2021
  11. brian m. carlsonMay 4, 2021
  12. Junio C HamanoMay 4, 2021
  13. Felipe ContrerasMay 5, 2021
  14. brian m. carlsonMay 5, 2021
  15. Felipe ContrerasMay 5, 2021
  16. Jeff KingMay 5, 2021
  17. Felipe ContrerasMay 5, 2021

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.