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

Re: [PATCH/alternative/raw and rough] setup.c: denote repo wide pathspecs by ':'

From
Michael J Gruber <git@drmicha.warpmail.net>
Date
Mar 1, 2011, 15:01 UTC
Message-ID
<4D6D0A51.9030701@drmicha.warpmail.net>
In-Reply-To
<7vsjv6evy4.fsf@alter.siamese.dyndns.org>
Junio C Hamano venit, vidit, dixit 01.03.2011 15:50:
Show 40 quoted lines
> Nguyen Thai Ngoc Duy <pclouds@gmail.com> writes:
> 
>> No. ':foo' as a reference to 'foo' in index is a SHA1-extended syntax
>> and I think we try to avoid ambiguation when a sha1-extended syntax
>> may look like a path or vice versa.
> 
> Very true.
> 
> Just as a thought experiment (I am skeptical about this whole "this is
> from root" prefix idea to begin with, but I don't want to shoot an idea
> down prematurely when there may still be untold gems I haven't seen in
> it):
> 
>     $ git grep -e frotz .../
> 
> to abbreviate "I don't bother to count my ../" might be an alternative,
> though.
> 
> The reason I am skeptical about the "from root prefix" is because I do not
> see a way to make it compatible with other meaningful pathspecs.
> 
>     $ cd Documentation
>     $ git grep -e frotz '*.txt'
> 
> would find frotz in all *.txt files in Documentation (and its
> subdirectories), if the command takes "relatigve to cwd".
> 
> It also is very clear that
> 
>     $ cd Documentation
>     $ git grep --full-tree -e frotz '*.txt'
> 
> would find those anywhere, inside or outside Documentation.
> 
> On the other hand, it is natural to expect that
> 
>     $ git grep -e frotz ".../*.txt"
> 
> should find *.txt files _only_ at the root level, so it is not as useful as
> the --full-tree (or --root).

Exactly that is (one of the reasons) why I used something which does not look like "as many ../ as necessary" nor like "/". With my implementation,

git grep -e frotz ":*.txt"
from a subdir will grep the exact same files as
(cd $(git rev-parse --cdup) && git grep -e frotz "*.txt")

will (it is --full-tree!), and will output the results relative to the current workdir.

Note that we already have to disambiguate between revspecs and pathspecs with -- in several places; that is not different with the new notation, and even not more frequent if it is not used.

I have to say I'm really excited about how transparently this works across all kinds of commands, and how suggestive this is with rev:path in mind.

Also, e.g.,
git grep -e frotz "*.c" ":*.h"

will look in all C files in the cwd and and all headers everywhere. Just think of the possibilities, and of the usefulness with clean, add, commit, reset,...!

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