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

Re: [RFC/PATCH] pathspec: allow escaped query values

From
Stefan Beller <sbeller@google.com>
Date
Jun 2, 2016, 02:20 UTC
Message-ID
<CAGZ79kZSB-r-GzS1WVtLk-sX068PDXQ1h-1FV-8YZFGGsr3hWQ@mail.gmail.com>
In-Reply-To
<574F800D.6070107@ramsayjones.plus.com>

On Wed, Jun 1, 2016 at 5:38 PM, Ramsay Jones <ramsay@ramsayjones.plus.com> wrote:

Show 27 quoted lines
>
>
> On 02/06/16 00:52, Stefan Beller wrote:
>> In our own .gitattributes file we have attributes such as:
>>
>>     *.[ch] whitespace=indent,trail,space
>>
>> When querying for attributes we want to be able to ask for the exact
>> value, i.e.
>>
>>     git ls-files :(attr:whitespace=indent,trail,space)
>>
>> should work, but the commas are used in the attr magic to introduce
>> the next attr, such that this query currently fails with
>>
>> fatal: Invalid pathspec magic 'trail' in ':(attr:whitespace=indent,trail,space)'
>>
>> This change allows escaping characters by a backslash, such that the query
>>
>>     git ls-files :(attr:whitespace=indent\,trail\,space)
>
> Not having given this much thought at all, but the question which comes
> to mind is: can you use some other separator for the <attr>-s rather than
> a comma? That way you don't need to quote them in the <value> part of the
> <attr>-spec.
>
> (I dunno, maybe use ; or : instead?)

That was essentially my proposal as well (just that I said "white spaces" instead if ':' or ';'), but it is not a good idea according to Junio as we don't want to need knowledge of the attr syntax here in the pathspec matching IIUC. We rather want "I want to transport this exact string for the match, but to go through the pathspec magic, we need to apply escaping of the exact string. That way we can change the attr system later without having to worry about the syntax replacements done in the pathspecs.

Show 6 quoted lines
>
> ATB,
> Ramsay Jones
>
>
>
Previous: Ramsay JonesNext: Junio C Hamano
Message 5 of 16 in “pathspec: allow escaped query values”
  1. pathspec: allow escaped query valuesStefan Beller, Jun 1, 2016
  2. Junio C HamanoJun 2, 2016
  3. Stefan BellerJun 2, 2016
  4. Ramsay JonesJun 2, 2016
  5. Stefan BellerJun 2, 2016
  6. Junio C HamanoJun 2, 2016
  7. Ramsay JonesJun 2, 2016
  8. Junio C HamanoJun 2, 2016
  9. Ramsay JonesJun 2, 2016
  10. Junio C HamanoJun 2, 2016
  11. Junio C HamanoJun 2, 2016
  12. Ramsay JonesJun 2, 2016
  13. Stefan BellerJun 2, 2016
  14. Ramsay JonesJun 2, 2016
  15. Junio C HamanoJun 2, 2016
  16. Ramsay JonesJun 2, 2016

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.