tried every answer from similar questions:
How to grep Git commit diffs or contents for a certain word?
Search all of Git history for a string?
How to grep (search) committed code in the Git history
none worked!
would it even be possible to search using anything other than git
itself?
repository tested: http://cregox.net
scenario
picture hundreds of markdown files, a dozens of which will have something like this:
---
title: lorem ipsum
description: foo, or not foo, it's not even a question
bar: false
(in practice, instead of foo
it was checklist
and instead of bar
i wanted published
)
expected
ag "foo[\s\S]*bar:\ "
will search all files with 1 foo
that happens before the first bar:
if they both exist.
all i needed was that, applied to git history.
that's it.
but...
reality
git log -G "foo[\s\S]*bar:\ "
instead of silversearcher-ag doesn't even work because of \s
.
i've tried many variations of regexp, couldn't find any single one that would work!
so that's something that i'll want to fix at some point, but meanwhile i also tried other alternatives...
git log -p -S foo
should bring something similar to rg foo
, but doesn't come even close to be readable and it's way too verbose.
git log --name-status --oneline -S foo
this was the closest i could get to the expected results... but it's still too cumbersome.
i give up digging for now.