* [RFD] not grep but not log -S
@ 2026-04-13 21:19 Junio C Hamano
2026-04-13 22:04 ` Mirko Faina
0 siblings, 1 reply; 2+ messages in thread
From: Junio C Hamano @ 2026-04-13 21:19 UTC (permalink / raw)
To: git
If you have a series of commits that record the contents of "what's
cooking" reports (i.e., "git log origin/todo -- whats-cooking.txt" in
your clone of this project), and have a specific topic name you are
interested in (e.g., "jc/test-set-e-clean"), what's the easiest way
to find out in which issues of the "what's cooking" report the topic
appeared?
$ git log -Sjc/test-set-e-clean -p whats-cooking.txt
would tell you when it appeared and when it went away, but does not
mention anything about the (potentially) multiple issues the topic
stayed in the report in between. Git being a tool to track contents
but is primarily used to track _changes_ in contents, this may be
unavoidable, but it is not very satisfying.
Looking for the string in each and every version, e.g.,
$ git grep jc/test-set-e-clean $(printf "HEAD~%d " $(seq 0 20)) \
whats-cooking.txt
may give something close to what I want, but it makes me feel dirty
that I have to _guess_ how many is sufficient.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [RFD] not grep but not log -S
2026-04-13 21:19 [RFD] not grep but not log -S Junio C Hamano
@ 2026-04-13 22:04 ` Mirko Faina
0 siblings, 0 replies; 2+ messages in thread
From: Mirko Faina @ 2026-04-13 22:04 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Mirko Faina
On Mon, Apr 13, 2026 at 02:19:49PM -0700, Junio C Hamano wrote:
> may give something close to what I want, but it makes me feel dirty
> that I have to _guess_ how many is sufficient.
If you know when it is introduced and when it goes away you don't have
to guess at all. You should be able to log start..end (and filtering the
appropiate subject line).
topic=jc/test-set-e-clean
git log $(git log --oneline -S$topic --reverse whats-cooking.txt | \
head -n1 | cut -d \ -f 1)~1..$(git log --oneline -S$topic \
--max-count=1 whats-cooking.txt | cut -d \ -f 1)
I know it's a bit long but this way you won't have to guess (and I'm
assuming is going in a script anyway). The log command to get the first
and last occurrence would go on their own line as well.
last=$(git log --oneline -Sjc/test-set-e-clean --max-count=1 \
whats-cooking.txt | cut -d \ -f 1)
first=$(git log --oneline -Sjc/test-set-e-clean --reverse \
whats-cooking.txt | head -n1 | cut -d \ -f 1)
git log $first~1..$last
I would've used --max-count=1 to get just the first occurrence instead
of using 'head', but '--reverse', '-S' and '--max-count' don't interact
in the way a user might obviously presume (and I'm assuming it's a bug).
P.S. sorry if I end up in your inbox twice, I forgot to cc the list.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-04-13 22:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-13 21:19 [RFD] not grep but not log -S Junio C Hamano
2026-04-13 22:04 ` Mirko Faina
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox