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, 15:30 UTC
Message-ID
<57505105.2000801@ramsayjones.plus.com>
In-Reply-To
<xmqqy46ouorn.fsf@gitster.mtv.corp.google.com>
On 02/06/16 06:46, Junio C Hamano wrote:
Show 39 quoted lines
> Ramsay Jones <ramsay@ramsayjones.plus.com> writes:
> 
>> 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?)
> 
> There are two kinds of comma involved in this discussion.
> 
>  * Multiple pathspec magic can be attached to augment the way
>    <pattern> selects paths. ":(<magic1>,<magic2>,...)<pattern>" is
>    the syntax, and <magicN> are things like "icase" (select the path
>    that matches <pattern> case-insensitively), "top" (<pattern> must
>    match from the top level of the working tree, even when you are
>    running the command from a subdirectory).  We added a new kind of
>    <magic> whose syntax is "attr:VAR=VAL" recently, which says "not
>    only <pattern> must match the path, in order to be selected, the
>    path must have the attribute VAR with value VAL".
> 
>    The comma that separates multiple magic is not something you can
>    change now; it has been with us since v1.7.6 (Jun 2011)
> 
>  * My example wanted to use the attr:VAR=VAL form to select those
>    paths that has one specific string as the value for whitespace
>    attribute, i.e. VAR in this case is "whitespace".  The value for
>    whitespace attribute determines what kind of whitespace anomalies
>    are considered as errors by "git apply" and "git diff", and it is
>    formed by concatenating things like "indent-with-non-tab" (starts
>    a line with more than 8 consecutive SPs), "space-before-tab" (a
>    SP appears immediately before HT in the indent), etc., with a
>    comma in between.
> 
>    The comma that separates various kinds of whitespace errors is
>    not something you can change now; it has been with us since
>    v1.5.4 (Feb 2008).
> 
> So using different separator is not a viable solution.

Ah, OK, makes sense. Note that I have not used 'pathspec magic' or the attribute system in git (never felt/had the need)! ;-)

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)'

[Hmm, I don't seem to be able to find documentation on the syntax of these features (apart from the code, of course).]

ATB, Ramsay Jones

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