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

Re: "git grep" and "working tree" vs "working directory"

From
Junio C Hamano <gitster@pobox.com>
Date
May 25, 2018, 00:55 UTC
Message-ID
<xmqqa7sor1t3.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<CAGZ79kavmH5KVS2Byc5+Hg3dOvVwGD11KZ3yzZTLwp8Ok9ZDTg@mail.gmail.com>
Stefan Beller <sbeller@google.com> writes:
Show 5 quoted lines
> There are 2 dimensions to it:
> * (where you are)
>   if you run git-grep from a sub directory of the repository, then the
> "sub-working-tree"
>   will be searched.
s/the repository/the top level directory of the working tree/, perhaps?
Show 12 quoted lines
>>   also, at the bottom of that section, one reads:
>>
>>   <pathspec>...
>>       If given, limit the search to paths matching at least one
>>       pattern. Both leading paths match and glob(7) patterns are supported.
>>
>>       For more details about the <pathspec> syntax, see the pathspec
>>       entry in gitglossary(7).
>>
>> but, again, what if <pathspec> is *not* given? then what?
>
> Assume "$pwd/."

This is not technically wrong per-se, but I do not think there is any reason to encourage it over just a simple "." dot.

Show 12 quoted lines
>>   finally, the first example has the same problem:
>>
>>   git grep 'time_t' -- '*.[ch]'
>>       Looks for time_t in all tracked .c and .h files in the
>>       working directory and its subdirectories.
>>
>> in "the working directory"?
>>
>>   what is the proper terminology to be used here?
>
> the working directory sounds right, not sure which aspect you want to be
> exposed more clearly.

"The part of the working tree below and including your current working directory", if you really want to be pedantic ;-).

But almost all the examples that show how to work _with_ Git inspecting and manipulating tracked contents assume that your current working directory _is_ inside a working tree of the repository you are working on, so the above is equivalent to "The current working directory" should be clear enough for most readers, I would think.

Previous: Stefan BellerNext: Robert P. J. Day
Message 3 of 4 in “"git grep" and "working tree" vs "working directory"”
  1. Robert P. J. DayMay 23, 2018
  2. Stefan BellerMay 24, 2018
  3. Junio C HamanoMay 25, 2018
  4. Robert P. J. DayMay 25, 2018

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.