All of lore.kernel.org
 help / color / mirror / Atom feed
* git grep --no-index and absolute paths don't work?
@ 2011-10-21  6:34 Bert Wesarg
  2011-10-21  7:09 ` Carlos Martín Nieto
  2011-10-21 17:00 ` Junio C Hamano
  0 siblings, 2 replies; 6+ messages in thread
From: Bert Wesarg @ 2011-10-21  6:34 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git Mailing List

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:

    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.

Any input is appreciate.

Thanks.

Bert

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: git grep --no-index and absolute paths don't work?
  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
  2011-10-21 17:00 ` Junio C Hamano
  1 sibling, 1 reply; 6+ messages in thread
From: Carlos Martín Nieto @ 2011-10-21  7:09 UTC (permalink / raw)
  To: Bert Wesarg; +Cc: Junio C Hamano, Git Mailing List

[-- Attachment #1: Type: text/plain, Size: 1058 bytes --]

On Fri, 2011-10-21 at 08:34 +0200, Bert Wesarg wrote:
> 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.

> 
>     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


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: git grep --no-index and absolute paths don't work?
  2011-10-21  7:09 ` Carlos Martín Nieto
@ 2011-10-21 11:49   ` Lars Noschinski
  2011-10-21 12:44     ` Bert Wesarg
  0 siblings, 1 reply; 6+ messages in thread
From: Lars Noschinski @ 2011-10-21 11:49 UTC (permalink / raw)
  To: Carlos Martín Nieto; +Cc: Bert Wesarg, Junio C Hamano, Git Mailing List

* 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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: git grep --no-index and absolute paths don't work?
  2011-10-21 11:49   ` Lars Noschinski
@ 2011-10-21 12:44     ` Bert Wesarg
  0 siblings, 0 replies; 6+ messages in thread
From: Bert Wesarg @ 2011-10-21 12:44 UTC (permalink / raw)
  To: Lars Noschinski
  Cc: Carlos Martín Nieto, Junio C Hamano, Git Mailing List

On Fri, Oct 21, 2011 at 13:49, Lars Noschinski
<lars@public.noschinski.de> wrote:
>  - automatic usage of pager
>  - support for pathspecs (can be emulated with `find ...`)
>  - support for boolean combinations of regular expressions
- thread parallel

bert

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: git grep --no-index and absolute paths don't work?
  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 17:00 ` Junio C Hamano
  2011-10-21 17:35   ` Bert Wesarg
  1 sibling, 1 reply; 6+ messages in thread
From: Junio C Hamano @ 2011-10-21 17:00 UTC (permalink / raw)
  To: Bert Wesarg; +Cc: Git Mailing List

Bert Wesarg <bert.wesarg@googlemail.com> writes:

> 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.

I think "in the current directory" is just contrasting with "in the work
tree, ..." at the beginning of the DESCRIPTION section. We could say "in
the files" instead for clarity, and then add "when pathspec is not given,
files in the current directory is searched" or something.

The intent of "--no-index", originating from "git diff --no-index", is to
allow git tools to be used in non-git context, i.e. to files on the
filesystem.

"git grep --no-index" which is a later invention in the 1.7.0 era didn't
fully ignore "git"ness, and one such instance you fixed in this thread:

    http://thread.gmane.org/gmane.comp.version-control.git/181484/focus=181485

I think this path normalization is another instance of us knowing a bit too
much of "git" even when we are told with "--no-index" that we are not
operating on a working tree associated with git.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: git grep --no-index and absolute paths don't work?
  2011-10-21 17:00 ` Junio C Hamano
@ 2011-10-21 17:35   ` Bert Wesarg
  0 siblings, 0 replies; 6+ messages in thread
From: Bert Wesarg @ 2011-10-21 17:35 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git Mailing List

On Fri, Oct 21, 2011 at 19:00, Junio C Hamano <gitster@pobox.com> wrote:
> Bert Wesarg <bert.wesarg@googlemail.com> writes:
>
>> 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.
>
> I think "in the current directory" is just contrasting with "in the work
> tree, ..." at the beginning of the DESCRIPTION section. We could say "in
> the files" instead for clarity, and then add "when pathspec is not given,
> files in the current directory is searched" or something.
>
> The intent of "--no-index", originating from "git diff --no-index", is to
> allow git tools to be used in non-git context, i.e. to files on the
> filesystem.
>
> "git grep --no-index" which is a later invention in the 1.7.0 era didn't
> fully ignore "git"ness, and one such instance you fixed in this thread:
>
>    http://thread.gmane.org/gmane.comp.version-control.git/181484/focus=181485
>

Thats why I'm completely rattled after trying an absolute path with
--no-index and it didn't worked.

> I think this path normalization is another instance of us knowing a bit too
> much of "git" even when we are told with "--no-index" that we are not
> operating on a working tree associated with git.
>

So we agree that this is a bug. Good. I will try to have a look into this.

Bert

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-10-21 17:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2011-10-21 12:44     ` Bert Wesarg
2011-10-21 17:00 ` Junio C Hamano
2011-10-21 17:35   ` Bert Wesarg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.