This is a job for the pickaxe!
From the git-log manpage:
-S<string>Look for differences that introduce or remove an instance of
<string>. Note that this is different than the string simply appearing in diff output; see the pickaxe entry in gitdiffcore(7) for more details.
You can of course use further options to narrow it down, for example:
git log -Sfoobar --since=2008.1.1 --until=2009.1.1 -- path_containing_change
There is also:
-G<regex>Look for differences whose patch text contains added/removed lines that match .
To illustrate the difference between -S –pickaxe-regex and -G, consider a commit with the following diff in the same file:
+ return frotz(nitfol, two->ptr, 1, 0);
...
- hit = frotz(nitfol, mf2.ptr, 1, 0);While
git log -G"frotz\(nitfol"will show this commit,git log -S"frotz\(nitfol" --pickaxe-regexwill not (because the number of occurrences of that string did not change).