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

Re: How to find a commit that introduces (not removes) a string?

From
VLVijay Lakshminarayanan <laksvij@gmail.com>
Date
Nov 3, 2011, 16:13 UTC
Message-ID
<87zkgdgp5q.fsf@gmail.com>
In-Reply-To
<j8to8h$vqd$1@dough.gmane.org>
Sebastian Schuberth <sschuberth@gmail.com> writes:
> Hi all,
>
> I know about git log's -S / -G, but I'm unable to make these search through *introduced* strings only. Is there a way to do so?
This appears to work:
$ for ref in `git log -SWORD --pretty=format:"%h"` ; do 
    git log -1 -p $ref | grep WORD | grep -E '^[+]' > /dev/null ; 
    if [ $? -eq 0 ]; then 
        echo $ref; 
    fi ;
  done

substitute WORD for what you're looking for. Note that it is repeated twice.

Show 5 quoted lines
> Thanks!
>
> PS: I also read [1], but although the author claims to be interested in introduced strings only, he seems to be satisfied with -G, which slightly puzzles me.
>
> [1] http://stackoverflow.com/questions/5816134/git-finding-a-commit-that-introduced-a-string
-- 
Cheers
~vijay
Previous: Neal KreitzingerNext: Sebastian Schuberth
Message 3 of 4 in “How to find a commit that introduces (not removes) a string?”
  1. Sebastian SchuberthNov 3, 2011
  2. Neal KreitzingerNov 3, 2011
  3. Vijay LakshminarayananNov 3, 2011
  4. Sebastian SchuberthNov 4, 2011

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.