git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lars Noschinski <lars@public.noschinski.de>
To: "Carlos Martín Nieto" <cmn@elego.de>
Cc: Bert Wesarg <bert.wesarg@googlemail.com>,
	Junio C Hamano <gitster@pobox.com>,
	Git Mailing List <git@vger.kernel.org>
Subject: Re: git grep --no-index and absolute paths don't work?
Date: Fri, 21 Oct 2011 13:49:52 +0200	[thread overview]
Message-ID: <20111021114952.GA2797@lars.home.noschinski.de> (raw)
In-Reply-To: <1319180973.5352.8.camel@bee.lab.cmartin.tk>

* Carlos Martín Nieto <cmn@elego.de> [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.

  reply	other threads:[~2011-10-21 11:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-21  6:34 git grep --no-index and absolute paths don't work? Bert Wesarg
2011-10-21  7:09 ` Carlos Martín Nieto
2011-10-21 11:49   ` Lars Noschinski [this message]
2011-10-21 12:44     ` Bert Wesarg
2011-10-21 17:00 ` Junio C Hamano
2011-10-21 17:35   ` Bert Wesarg

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=20111021114952.GA2797@lars.home.noschinski.de \
    --to=lars@public.noschinski.de \
    --cc=bert.wesarg@googlemail.com \
    --cc=cmn@elego.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /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).