Re: git-grep to operate across who repository and not just CWD?

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

 



(cc list: Pardon this duplicate attempt)

On 02/28/2011 04:27 AM, Michael J Gruber wrote:
> David Chanters venit, vidit, dixit 28.02.2011 01:17:
>> > Hi all,
>> > 
>> > [ Please Cc me as I am not subscribed to this list, thanks. ]
>> > 
>> > I'm wondering if there's an easy way to get git-grep (and I suppose
>> > other commands which operate on a per-repository level rather than
>> > per-tree) to work across the whole repository?
> git grep -- $(git rev-parse --show-cdup)
>
> is the best we have right now. I think we're still looking for a good
> way to denote "root of repo" (like "." for cwd).
>
> Also, we're thinking of changing a few defaults (to repo-wide), but "git
> grep" is meant to stay close to ordinary grep.

But git grep is different than grep in exactly the "files selection"
area.  With grep, I always have to specify the files to search.  With
git-grep, I don't.

Oridinary grep with no paths fails (reads stdin), so when I make this
mistake it is always immediately evident. I retry the command with
paths/wildcards.  But git-grep with no path "works" and I am likely to
forget that it worked only on my $PWD.

git-grep also includes subdirectories and excludes untracked files by
default.  This makes git-grep feel like the "repository grep" tool that
it is. The fact that it does _not_ search from the top of the repository
by default seems (to me) to be the only oddball case.

I would be much more comfortable with David's proposed option turned on
always.  When I want to search "here", I can add a dot.

  git grep foo       # search the whole repository
  git grep foo -- .  # Search only from $PWD

Maybe it's dangerous as an always-on option, as it can break scripts. 
And I'd be happy-ish even with a --full-tree option.  But I think I
would eventually alias it so it always does what I expect.

I know that's not what the original question was, but it's the behavior
I often erroneously expect.

Thoughts?

Phil

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