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

Re: [PATCH] pathspec: reserve some letters after a colon pathspec

From
Michael J Gruber <git@drmicha.warpmail.net>
Date
Mar 24, 2011, 07:15 UTC
Message-ID
<4D8AEF9B.9050001@drmicha.warpmail.net>
In-Reply-To
<7vvcz9emrn.fsf@alter.siamese.dyndns.org>
Junio C Hamano venit, vidit, dixit 23.03.2011 19:04:
Show 52 quoted lines
> Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:
> 
>> Pathspec ':something' means 'something' at top directory. Limit it a
>> bit so that ':<non-alnum>something' can be reserved for future
>> extensions. ':\<non-alnum>something' can be used to achieve
>> ':something' before this patch.
>>
>> All non-alphanumeric chars on the en_US keyboard, except \ and ., are
>> currently reserved.
> 
> While I was writing the other message, I really was hoping that people
> would notice that trying to limit the magic signature (i.e. "which magic I
> want" in my previous message) to a non-alnum letter that cannot easily be
> remembered would be a bad direction.  A set of short mnemonic is fine, but
> we probably should prepare the syntax framework to reserve spelled out
> magic names for readability.
> 
> Here is a weather-baloon.  I will use colon below as the magic introducer,
> as I don't care very deeply about the choice of it.
> 
>  - "^:([^\w\d]+)(.*)$", that is "a magic introducer followed by a sequence
>    of non-alnum followed by the remainder" means that the part that is
>    given to the matching engine is $2, and each gibberish character in $1
>    determines what magic is requested when the matching engine does its
>    work.  Among the gibberish that can be in $1, we currently would want
>    to support:
> 
>     . '/' denotes that $2 is relative to root of the working tree, i.e. do
>       not add 'prefix' to it at the left.
> 
>     . '!' denotes that the matching with $2 should not honor globbing.
> 
>    e.g.
> 
>     ":/*lib/**/foo.h", if '*' denoted recursive glob support for '**/' to
>     mean "zero-or-more levels of any directory" [*1*], it would find any
>     foo.h in a directory 'lib' or its subdirectory that is found in
>     anywhere in the working tree.
> 
>  - "^:((?:[-a-z]+)(?:,[-a-z+]+)*):(.*)$", that is "a magic introducer,
>    followed by one or more alpha-string separated with comma, followed
>    by a magic terminator, and the remainder" means that the remainder is
>    what is given to the matching engine, and the alpha-strings spell out
>    the name of the magic.  We currently would want to support:
> 
>     . 'full-tree' means exactly the same as '/' mnemonic above.
>     . 'noglob' means exactly the same as '!' mnemonic.
> 
>    e.g.
> 
>    ":full-tree,recursive-glob:lib/**/foo.h" would be how you fully spell
>    the above example in the mnemonic section [*2*].

I like this a lot, especially the fact that we would have descriptive long names as well as short versions for a subset! Two remarks:

:(symlink|submodule|directory|file): would fit into that scheme (for use in .gitattributes), though I'm not sure we want that for general pathspecs. We probably want textconv applied to :file: only by default, attributes to match with :file only?

We already have ":./cdwfile" as in "commit:./cwdfile", and this looks like a preexisting instance, although it is not ("commit:" gets stripped and "./cwdfile" is the pathspec). People will probably try something like "commit:/rootfile", and we may or may not want to support this. That particular one is easy, but "commit:full-tree:name" has a defined meaning now...

Michael
Previous: Junio C HamanoNext: Nguyen Thai Ngoc Duy
Message 43 of 46 in “git-grep to operate across who repository and not just CWD?”
  1. David ChantersFeb 28, 2011
  2. Michael J GruberFeb 28, 2011
  3. Jay SoffianFeb 28, 2011
  4. Junio C HamanoFeb 28, 2011
  5. Junio C HamanoFeb 28, 2011
  6. Phil HordFeb 28, 2011
  7. Michael J GruberMar 1, 2011
  8. Nguyen Thai Ngoc DuyMar 1, 2011
  9. Michael J GruberMar 1, 2011
  10. Nguyen Thai Ngoc DuyMar 1, 2011
  11. Nguyen Thai Ngoc DuyMar 1, 2011
  12. 0/2 grep --full-treeMichael J Gruber, Mar 1, 2011
  13. 1/2 grep: --full-treeMichael J Gruber, Mar 1, 2011
  14. 2/2 grep: make --full-tree work with pathspecsMichael J Gruber, Mar 1, 2011
  15. Junio C HamanoMar 1, 2011
  16. setup.c: denote repo wide pathspecs by ':'Michael J Gruber, Mar 1, 2011
  17. Nguyen Thai Ngoc DuyMar 1, 2011
  18. Michael J GruberMar 1, 2011
  19. Nguyen Thai Ngoc DuyMar 1, 2011
  20. Michael J GruberMar 1, 2011
  21. Nguyen Thai Ngoc DuyMar 1, 2011
  22. Junio C HamanoMar 1, 2011
  23. Michael J GruberMar 1, 2011
  24. Junio C HamanoMar 1, 2011
  25. Sverre RabbelierMar 2, 2011
  26. Nguyen Thai Ngoc DuyMar 2, 2011
  27. Michael J GruberMar 2, 2011
  28. Junio C HamanoMar 2, 2011
  29. Michael J GruberMar 2, 2011
  30. Miles BaderMar 3, 2011
  31. Junio C HamanoMar 3, 2011
  32. Phil HordMar 3, 2011
  33. Michael J GruberMar 3, 2011
  34. Phil HordMar 1, 2011
  35. James PickensMar 1, 2011
  36. Nguyen Thai Ngoc DuyMar 2, 2011
  37. Phil HordMar 3, 2011
  38. Michael J GruberMar 3, 2011
  39. Michael J GruberMar 1, 2011
  40. Phil HordMar 1, 2011
  41. pathspec: reserve some letters after a colon pathspecNguyễn Thái Ngọc Duy, Mar 23, 2011
  42. Junio C HamanoMar 23, 2011
  43. Michael J GruberMar 24, 2011
  44. Nguyen Thai Ngoc DuyMar 24, 2011
  45. Junio C HamanoMar 24, 2011
  46. Junio C HamanoMar 24, 2011

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.