New "west grep" shortcut for west forall -c 'git grep <pattern>'
See original GitHub issuegit
has a built-in git grep
command that is convenient to perform a recursive search in sources. It’s very convenient because
- it automatically excludes binary
.git/
database files and built artefacts, - it works well “out of the box” requiring zero configuration or hard to remember option or parameter
- it supports
grep
’s standard and familiar user interface / syntax - it’s built-in requiring zero additional installation
- it’s extremely short to type
- it’s seems faster than the equivalent recursive grep . Maybe because it’s multithreaded by default?
In a multi repo project, developers sometimes need to search across repos. Either because the project has (too) many repos and they need a reminder, or because some symbol is actually used across multiple repos, or because <share other reasons below>.
west forall -c 'git grep <pattern>'
is then the obvious solution, however it loses a lot of the convenience listed above and introduces additional and non-portable quoting complexity.
It’s probably why git-repo already has the repo grep
shortcut.
@mbolivar on Slack:
I would like people to start asking for features on GitHub, and voting with emoji.
I’ve recently learned that a feature I’ve been working on for a long time is not expected to be useful to the people I’ve been making it for, and there are a lot of directions we can go with west, I want to start making some sort of priority queue based on user feedback I want to be clear that I’m happy to discuss features in here [on Slack], but I’d like to start asking for more issues filed for new features before I at least start implementing. There are already quite a few enhancements open (edited) And TBH I think it’s rather easy to write a shell function to wrap your favorite grep-a-like, so without more people asking for it, I’m not inclined to make it a built-in command
In a different context:
just try to be conservative about adding [top-level built-in commands] unless they’re really needed.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:6
- Comments:17 (5 by maintainers)
Sounds good, I’ll think of a couple use cases at work and have a look at the code and open a new issue.
This got four +1 emojis and one -1 so far. Thanks for voting, everyone. It seems like the general reaction is positive.
Yep, I’m a strong -1 on --git-diff-arg type options.
So the signature would be something like:
and the semantics would be equivalent to
??
Would I be correct to say that providing a single
west forallgit
, plus awest alias
command that would let you runonce, and then subsequently
west grep
would mean the same thing aswest forallgit grep
, might be satisfactory?I wonder if there’s a more generic way to provide a “forall alias” type function that doesn’t assume git.