Re: git grep --no-index and absolute paths don't work?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



* Carlos Martín Nieto <cmn@xxxxxxxx> [11-10-21 09:09]:
> On Fri, 2011-10-21 at 08:34 +0200, Bert Wesarg wrote:
> > I'm currently  totally confused, that a
> > 
> >     git grep --no-index foo /usr/include
> > 
> > does not work. I know that the documentation says "in the current
> > directory" for the --no-index flag. But this does not work ether:
> 
> The rest of the sentence reads ", not just those tracked by git" which
> implies that the files tracked by git are also searched. This requires a
> git repository.

git grep --no-index works outside of git repositories (at least with
relative paths).

> >     cd ~; git grep --no-index foo ~/.bashrc
> > 
> > They all fail with 'is outside repository'. Which is for itself vary
> > misleading, because I intentionally said --no-index.
> 
> Git is a tool that works on git repositories. Some commands may work
> outside of a repository, like ls-remote when given an URL or init (for
> obvious reasons) but it's not something that should be expected,
> especially for commands that read files from the working tree.
> 
> Why are you trying to use git's grep command outside a repository? Why
> isn't 'grep -nr foo /usr/include/' good enough?

There are a few nice things about git's grep, which GNU grep does not
have:

  - automatic usage of pager
  - support for pathspecs (can be emulated with `find ...`)
  - support for boolean combinations of regular expressions

  -- Lars.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]