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

Re: RFH - git-log variant that _does_ search through diffs

From
EREric Raible <raible@gmail.com>
Date
Jun 30, 2009, 18:05 UTC
Message-ID
<279b37b20906301105tf92f471g6146a083ba2e2882@mail.gmail.com>
In-Reply-To
<20090630040337.GA23741@sigio.peff.net>
On Mon, Jun 29, 2009 at 9:03 PM, Jeff King<peff@peff.net> wrote:
Show 6 quoted lines
> You can at least combine rev-list and diff into one command, and grep
> like this (for 'foo'):
>
>  git log -z -p | perl -0ne 'print if /^[-+].*foo/m' | tr '\0' '\n'
>
> -Peff
Thank you, that will do very nicely as a starting point.

What I _really_ want is the subset of all commits containing foo who's oneline commit message doesn't match a given regexp.

So I'm used something like this to extract the commits of interest:

git log -z -p | perl -0ne 'print if /^[-+].*foo/m' | tr '\0' '\n' | grep "^commit [0-9a-f]" | awk '{print $2}' | xargs -n1 git log --pretty=oneline -1 | grep -v dont_want

In this specific case of wanting to ignore particular commits a loop over git-rev-list might yield a better solution. But the 'git-log | perl | tr' snippet is a nice idiom for day-to-day use.

Previous: Eric RaibleNext: Jeff King
Message 5 of 12 in “RFH - git-log variant that _does_ search through diffs”
  1. Eric RaibleJun 30, 2009
  2. Jeff KingJun 30, 2009
  3. Junio C HamanoJun 30, 2009
  4. Eric RaibleJun 30, 2009
  5. Eric RaibleJun 30, 2009
  6. Jeff KingJun 30, 2009
  7. Eric RaibleJun 30, 2009
  8. Eric RaibleJun 30, 2009
  9. Jeff KingJul 1, 2009
  10. 1/2 log-tree: fix confusing commentJeff King, Jul 1, 2009
  11. 2/2 fix missing NUL termination with pretty=tformatJeff King, Jul 1, 2009
  12. Junio C HamanoJul 1, 2009

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.