From: "Robert P. J. Day" <rpjday@crashcourse.ca>
To: Git Mailing list <git@vger.kernel.org>
Subject: "git grep" and "working tree" vs "working directory"
Date: Wed, 23 May 2018 14:50:12 -0400 (EDT) [thread overview]
Message-ID: <alpine.LFD.2.21.1805231434010.28811@localhost.localdomain> (raw)
more puzzling terminology, this time in the man page for "git grep".
the SYNOPSIS shows, at the very end, the clearly optional
"[<pathspec>...]",
git grep ...
... snip ...
[--] [<pathspec>...]
but nowhere in the man page is there an explanation as to the default
value used if there is no pathspec, and here's why that's confusing.
first, what is the proper phrase for the *entire* checked out repo?
working tree? working directory? either? and is that the proper phrase
to use *regardless* of where you happen to be located, perhaps in a
subdirectory?
i did a quick test and, if i don't supply a pathspec, then "git
grep" (quite reasonably) recursively searches only the *current*
working directory (example from linux kernel source repo):
$ cd scripts
$ git grep -il torvalds --
checkstack.pl
get_maintainer.pl
package/mkdebian
$
however, if you peruse the very first part of the OPTIONS section of
that man page, you read:
--cached
Instead of searching tracked files in the working tree,
search blobs registered in the index file.
--no-index
Search files in the current directory that is not managed by Git.
--untracked
In addition to searching in the tracked files in the
working tree, search also in untracked files.
... snip ...
note how a couple of those options are described as searching "the
working tree", when they clearly(?) do no such thing if you happen to
be located in a subdirectory.
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?
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?
rday
--
========================================================================
Robert P. J. Day Ottawa, Ontario, CANADA
http://crashcourse.ca/dokuwiki
Twitter: http://twitter.com/rpjday
LinkedIn: http://ca.linkedin.com/in/rpjday
========================================================================
next reply other threads:[~2018-05-23 18:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-23 18:50 Robert P. J. Day [this message]
2018-05-24 20:50 ` "git grep" and "working tree" vs "working directory" Stefan Beller
2018-05-25 0:55 ` Junio C Hamano
2018-05-25 10:56 ` Robert P. J. Day
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.LFD.2.21.1805231434010.28811@localhost.localdomain \
--to=rpjday@crashcourse.ca \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).