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

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

From
Carlos Martín Nieto <cmn@elego.de>
Date
Oct 21, 2011, 07:09 UTC
Message-ID
<1319180973.5352.8.camel@bee.lab.cmartin.tk>
In-Reply-To
<CAKPyHN138OZRt_3PT5ChuTpSEuOdybnyAj8Baqr=3OD=y==jgw@mail.gmail.com>
On Fri, 2011-10-21 at 08:34 +0200, Bert Wesarg wrote:
Show 8 quoted lines
> Hi,
> 
> 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.

Show 5 quoted lines
> 
>     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?

   cmn
Previous: Bert WesargNext: Lars Noschinski
Message 2 of 6 in “git grep --no-index and absolute paths don't work?”
  1. Bert WesargOct 21, 2011
  2. Carlos Martín NietoOct 21, 2011
  3. Lars NoschinskiOct 21, 2011
  4. Bert WesargOct 21, 2011
  5. Junio C HamanoOct 21, 2011
  6. Bert WesargOct 21, 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.