question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

New "west grep" shortcut for west forall -c 'git grep <pattern>'

See original GitHub issue

git 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:open
  • Created 4 years ago
  • Reactions:6
  • Comments:17 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
lindblandrocommented, Dec 13, 2022

Sounds good, I’ll think of a couple use cases at work and have a look at the code and open a new issue.

1reaction
mbolivarcommented, Dec 10, 2019

This got four +1 emojis and one -1 so far. Thanks for voting, everyone. It seems like the general reaction is positive.

The problem with solutions like --git-diff-arg is always the same: nesting makes quoting much more challenging because it messes with the levels of interpretation.

Yep, I’m a strong -1 on --git-diff-arg type options.

How about a generic west forallgit diff repo1 repo2 -- diffargs where forallgit passes any git command through?

So the signature would be something like:

west forallgit GIT_COMMAND [PROJECT ...] -- [GIT_COMMAND_ARGS]

and the semantics would be equivalent to

west forall -c 'GIT_COMMAND GIT_COMMAND_ARGS' [PROJECT ...]

??

Would I be correct to say that providing a single west forallgit, plus a west alias command that would let you run

west alias grep 'forallgit grep'

once, and then subsequently west grep would mean the same thing as west 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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Git - git-grep Documentation - Git SCM
Patterns are lists of one or more search expressions separated by newline characters. An empty string as search expression matches all lines. OPTIONS....
Read more >
hg
PATTERN [FILE]... Search revision history for a regular expression in the specified files or the entire project. By default, grep prints the most...
Read more >
Git Cheat Sheet
Define the author email to be used for all commits by the current user. git config --global user.email <email>. Create shortcut for a...
Read more >
qno - River Thames Conditions - Environment Agency - GOV.UK
Bysommer grep, Express yourself labrinth mp3 file. ... Oficina indecopi cusco, Fine cotton scandal 1984, Kanye west big brother live, Erin elaine moriarty, ......
Read more >
PDF - Zephyr Project Documentation
Next, clone Zephyr and its modules into a new west workspace named zephyrproject. ... it is a good idea to run git grep...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found