{"thread":{"id":"65477","subject":"[RFD] not grep but not log -S","startedAt":"2026-04-13T21:19:52Z","lastAt":"2026-04-13T22:04:56Z","messageCount":2,"participants":["Junio C Hamano","Mirko Faina"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"541499","messageId":"xmqq4ileh822.fsf@gitster.g","threadId":"65477","inReplyTo":null,"subject":"[RFD] not grep but not log -S","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-04-13T21:19:49Z","receivedAt":"2026-04-13T21:19:52Z","isPatch":false,"body":"If you have a series of commits that record the contents of \"what's\ncooking\" reports (i.e., \"git log origin/todo -- whats-cooking.txt\" in\nyour clone of this project), and have a specific topic name you are\ninterested in (e.g., \"jc/test-set-e-clean\"), what's the easiest way\nto find out in which issues of the \"what's cooking\" report the topic\nappeared?\n\n   $ git log -Sjc/test-set-e-clean -p whats-cooking.txt\n\nwould tell you when it appeared and when it went away, but does not\nmention anything about the (potentially) multiple issues the topic\nstayed in the report in between.  Git being a tool to track contents\nbut is primarily used to track _changes_ in contents, this may be\nunavoidable, but it is not very satisfying.\n\nLooking for the string in each and every version, e.g.,\n\n    $ git grep jc/test-set-e-clean $(printf \"HEAD~%d \" $(seq 0 20)) \\\n\t\t\twhats-cooking.txt\n\nmay give something close to what I want, but it makes me feel dirty\nthat I have to _guess_ how many is sufficient.\n"},{"id":"541502","messageId":"ad1oMLdO4ZMVo__O@exploit","threadId":"65477","inReplyTo":"xmqq4ileh822.fsf@gitster.g","subject":"Re: [RFD] not grep but not log -S","fromName":"Mirko Faina","fromEmail":"mroik@delayed.space","sentAt":"2026-04-13T22:04:39Z","receivedAt":"2026-04-13T22:04:56Z","isPatch":false,"body":"On Mon, Apr 13, 2026 at 02:19:49PM -0700, Junio C Hamano wrote:\n> may give something close to what I want, but it makes me feel dirty\n> that I have to _guess_ how many is sufficient.\n\nIf you know when it is introduced and when it goes away you don't have\nto guess at all. You should be able to log start..end (and filtering the\nappropiate subject line).\n\n    topic=jc/test-set-e-clean\n    git log $(git log --oneline -S$topic --reverse whats-cooking.txt | \\\n        head -n1 | cut -d \\  -f 1)~1..$(git log --oneline -S$topic \\\n        --max-count=1 whats-cooking.txt | cut -d \\  -f 1)\n\nI know it's a bit long but this way you won't have to guess (and I'm\nassuming is going in a script anyway). The log command to get the first\nand last occurrence would go on their own line as well.\n\n    last=$(git log --oneline -Sjc/test-set-e-clean --max-count=1 \\\n        whats-cooking.txt | cut -d \\  -f 1)\n    first=$(git log --oneline -Sjc/test-set-e-clean --reverse \\\n        whats-cooking.txt | head -n1 | cut -d \\  -f 1)\n    git log $first~1..$last\n\nI would've used --max-count=1 to get just the first occurrence instead\nof using 'head', but '--reverse', '-S' and '--max-count' don't interact\nin the way a user might obviously presume (and I'm assuming it's a bug).\n\n\nP.S. sorry if I end up in your inbox twice, I forgot to cc the list.\n"}]}