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

Re: [PATCH v3] ci: disallow directional formatting

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Nov 4, 2021, 13:48 UTC
Message-ID
<211104.86ee7whvoz.gmgdl@evledraar.gmail.com>
In-Reply-To
<pull.1071.v3.git.1636031609982.gitgitgadget@gmail.com>
On Thu, Nov 04 2021, Johannes Schindelin via GitGitGadget wrote:
Show 7 quoted lines
> From: Johannes Schindelin <johannes.schindelin@gmx.de>
> [...]
>      * Corrected a code comment: my custom git grep was not PCRE-enabled,
>        but Ubuntu's isn't. But git grep -P still does not understand \uNNNN.
>      * Even if the *.po files currently pass the check, the script is now
>        future-proof by excluding them.
> [...]
Show 24 quoted lines
> +# This is intended to run on an Ubuntu agent in a GitHub workflow.
> +#
> +# To allow translated messages to introduce such directional formatting in the
> +# future, we exclude the `.po` files from this validation.
> +#
> +# Neither GNU grep nor `git grep` (not even with `-P`) handle `\u` as a way to
> +# specify UTF-8.
> +#
> +# To work around that, we use `printf` to produce the pattern as a byte
> +# sequence, and then feed that to `git grep` as a byte sequence (setting
> +# `LC_CTYPE` to make sure that the arguments are interpreted as intended).
> +#
> +# Note: we need to use Bash here because its `printf` interprets `\uNNNN` as
> +# UTF-8 code points, as desired. Running this script through Ubuntu's `dash`,
> +# for example, would use a `printf` that does not understand that syntax.
> +
> +# U+202a..U+2a2e: LRE, RLE, PDF, LRO and RLO
> +# U+2066..U+2069: LRI, RLI, FSI and PDI
> +regex='(\u202a|\u202b|\u202c|\u202d|\u202e|\u2066|\u2067|\u2068|\u2069)'
> +
> +! LC_CTYPE=C git grep -El "$(LC_CTYPE=C.UTF-8 printf "$regex")" \
> +	-- ':(exclude,attr:binary)' ':(exclude)*.po'
>
> base-commit: 0cddd84c9f3e9c3d793ec93034ef679335f35e49

So this is still using not-PCRE instead of the much simpler PCRE-enabled one I suggested in[1] because your locally-built git doesn't link to libpcre?

At the very least that comment is still quite confusing. I.e. it starts out by saying that it's meant to run in CI where we've got PCRE, but then goes on to describe an elaborate workaround that's only needed with a not-PCRE grep.

Would be less confusing to understand why it's so complex as:
   # This is intended to run on an Ubuntu agent in a GitHub
   # workflow. We've got PCRE there, so all of the below could also be:
   #
   #    ! git -P grep -nP '[\N{U+202a}-\N{U+202e}\N{U+2066}-\N{U+2069}]' ':!(attr:binary)' ':!**po/**'
   #
   #
   # But the author wanted to run this locally on a system that didn't
   # have PCRE, So [go on to describe elaborate bash / "git grep -E" /
   # LC_* tweaking workaround....]
   [...]

B.t.w. I think that **po/** exclusion is closer to what you want, i.e. "a 'po' dir anywhere in our tree". It'll also exclude this if we e.g. end up using these in language-specific README files there or whatever.

1. https://lore.kernel.org/git/211103.86zgqlhzvz.gmgdl@evledraar.gmail.com/ or:
   ! git -P grep -nP '[\N{U+202a}-\N{U+202e}\N{U+2066}-\N{U+2069}]' ':!(attr:binary)'
Previous: Johannes Schindelin via GitGitGadgetNext: Junio C Hamano
Message 14 of 18 in “ci: disallow directional formatting”
  1. ci: disallow directional formattingJohannes Schindelin via GitGitGadget, Nov 2, 2021
  2. Ævar Arnfjörð BjarmasonNov 2, 2021
  3. Taylor BlauNov 2, 2021
  4. Ævar Arnfjörð BjarmasonNov 2, 2021
  5. Johannes SchindelinNov 2, 2021
  6. Ævar Arnfjörð BjarmasonNov 2, 2021
  7. Junio C HamanoNov 3, 2021
  8. ci: disallow directional formattingJohannes Schindelin via GitGitGadget, Nov 3, 2021
  9. Junio C HamanoNov 3, 2021
  10. Ævar Arnfjörð BjarmasonNov 3, 2021
  11. Junio C HamanoNov 3, 2021
  12. Johannes SchindelinNov 4, 2021
  13. ci: disallow directional formattingJohannes Schindelin via GitGitGadget, Nov 4, 2021
  14. Ævar Arnfjörð BjarmasonNov 4, 2021
  15. Junio C HamanoNov 4, 2021
  16. Ævar Arnfjörð BjarmasonNov 8, 2021
  17. Junio C HamanoNov 8, 2021
  18. Ævar Arnfjörð BjarmasonNov 9, 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.