I know this question's been answered for a while now, but I came across this as well and found a different solution so I thought I'd share. Git-log's -G switch should do what you're aksing, where the -S switch would only output commits where the number of occurences of the matched string changes.
From git-log's man page:
-G
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 !regexec(regexp, two->ptr, 1, ®match, 0);
...
- hit = !regexec(regexp, mf2.ptr, 1, ®match, 0);
While git log -G"regexec(regexp" will show this commit, git log -S"regexec(regexp" --pickaxe-regex will not (because the number of occurrences of that string did not change).
See the pickaxe entry in gitdiffcore(7) for more information.