The example is correct, but we can make it easier to untangle by avoiding writing "regex.*" unless it's really needed to make our point. When we exemplify the difference between -G and -S (using -pickaxe-regex), we do so using an example diff and git diff invocation involving "regexec", "regexp", "regmatch", etc. (Merged by Junio C Hamano - gitster - in commit 0d11410, ) diff-options.txt: avoid "regex" overload in the example \ 2020), the documentation is clarified around those regexes.
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). hit = !regexec(regexp, mf2.ptr, 1, ®match, 0) 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).
Note that -G by default accepts a regex, while -S accepts a string, but it can be modified to accept regexes using the -pickaxe-regex. To look for differences whose added or removed line matches "word" (also commit contents). In modern Git there is also $ git log -Gword If you want to find all commits where "word" was added or removed in the file contents (to be more exact: where the number of occurrences of "word" changed), i.e., search the commit contents, use a so-called 'pickaxe' search with $ git log -Sword If you want to find all commits where the commit message contains a given word, use $ git log -grep=word