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

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

From
Ramsay Jones <ramsay@ramsayjones.plus.com>
Date
Jun 2, 2016, 18:42 UTC
Message-ID
<57507DFD.6010800@ramsayjones.plus.com>
In-Reply-To
<xmqqoa7jvag0.fsf@gitster.mtv.corp.google.com>
On 02/06/16 17:10, Junio C Hamano wrote:
Show 13 quoted lines
> Ramsay Jones <ramsay@ramsayjones.plus.com> writes:
> 
>> So, at risk of annoying you, let me continue in my ignorance a little
>> longer and ask: even if you have to protect all of this 'magic' from
>> the shell with '/" quoting, could you not use (nested) quotes to
>> protect the <value> part of an <attr>? For example:
>>
>>     git ls-files ':(attr:whitespace="indent,trail,space",icase)'
> 
> That would be workable, I would think.  Before attr:VAR=VAL
> extention, supported pathspec <magic> were only single lowercase-ascii
> alphabet tokens, so nobody would have used " as a part of magic.  So
> quting with double-quote pair would work.
I was thinking about both ' and ", so that you could do:
   $ ./args ':(attr:whitespace="indent,trail,space",icase)'
    1::(attr:whitespace="indent,trail,space",icase)
   $ ./args ":(attr:whitespace='indent,trail,space',icase)"
    1::(attr:whitespace='indent,trail,space',icase)
   $ p=':(attr:whitespace="indent,trail,space",icase)'
   $ ./args "$p"
    1::(attr:whitespace="indent,trail,space",icase)
   $ p=":(attr:whitespace=\"indent,trail,space\",icase)"
   $ ./args "$p"
    1::(attr:whitespace="indent,trail,space",icase)
but limiting it to " would probably be OK too.
> You'd need to come up with a way to quote a double quote that
> happens to be a part of VAL somehow, though.

Yes I was assuming \ quoting as well - I just want to reduce the need for such quoting (especially on windows).

Show 13 quoted lines
>                                              I think attribute
> value is limited to a string with non-whitespace letters; even
> though the built-in attributes that have defined meaning to the Git
> itself may not use values with letters beyond [-a-zA-Z0-9,], end
> users and projects can add arbitrary values within the allowed
> syntax, so it is not unconceivable that some project may have a
> custom attribute that lists forbidden characters in a path with
> 
> 	=== .gitattributes ===
>         *.txt forbidden=`"
> 
> that tells their documentation cannot have these letters in it, or
> something like that.
Heh, yeah, that gets ugly:
   $ ./args ":(attr:*.txt forbidden=\'\\\",icase)"
    1::(attr:*.txt forbidden=\'\",icase)
   $ ./args ':(attr:*.txt forbidden=\'\''\",icase)'
    1::(attr:*.txt forbidden=\'\",icase)
[Note the initial ' 1:' above is output from args]

ATB, Ramsay Jones

Previous: Junio C HamanoNext: Junio C Hamano
Message 9 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.