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

Re: [PATCH] t6300: values containing ')' are broken in ref formats

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 6, 2024, 01:18 UTC
Message-ID
<xmqqikt1qhwt.fsf@gitster.g>
In-Reply-To
<20241105190235.13502-1-five231003@gmail.com>
Kousik Sanagavarapu <five231003@gmail.com> writes:
> Document that values containing ')' in formats are not parsed correctly
> in ref-filter.

The problem is probably lack of a way to quote such a closing parenthesis.

> However formats having a '(' instead in "value" will parse correctly
> because in a general format string we also mark start of the format by
> making note of '%(' instead of just '('.

So if you wanted to have a two-char sequence '%(' in value, you'd see a similar problem? If so, it is not quite a "bug" or "not parsed correctly"---it is "because there is no way to include closing ')' in the value (e.g., by quoting), you cannot write such a string in the value part".

> This raises the question of what can be done to parse ')' in values of
> the format correctly.  It seems to me like a clean solution would
> involve a huge refactoring involving a large portion of ref-filter but I
> maybe wrong.

Yes, so I wouldn't even call the current behaviour "bug". The language is merely "limited" and the user cannot express certain values with it at all.

Having said that, I just tried this
    $ git for-each-ref --format='%28%(refname)%29' refs/heads/master
    (refs/heads/master)

So, if there is anything that needs "fixing", wouldn't it be documentation?

If I knew (or easily find out from "git for-each-ref --help") that hex escapes %XX can be used, I wouldn't have written any of what I said before "Having said that" in this response.

Previous: Kousik SanagavarapuNext: Jeff King
Message 2 of 14 in “t6300: values containing ')' are broken in ref formats”
  1. t6300: values containing ')' are broken in ref formatsKousik Sanagavarapu, Nov 5, 2024
  2. Junio C HamanoNov 6, 2024
  3. Jeff KingNov 6, 2024
  4. Junio C HamanoNov 6, 2024
  5. Kousik SanagavarapuNov 6, 2024
  6. Jeff KingNov 6, 2024
  7. Kousik SanagavarapuNov 7, 2024
  8. Jeff KingNov 6, 2024
  9. Kousik SanagavarapuNov 7, 2024
  10. Junio C HamanoNov 7, 2024
  11. Kousik SanagavarapuNov 8, 2024
  12. Jeff KingNov 8, 2024
  13. Kousik SanagavarapuNov 8, 2024
  14. Kousik SanagavarapuNov 6, 2024

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.