How to list all files in one Git declaration with some text change in diff?

I found in yet another answer that I can list the files changed in the commit with:

git diff-tree --no-commit-id --name-only -r bd61ad98

      

How can I then only show files that contain a specific text change in diff?

+3


source to share


1 answer


You can use a -G

flag
:

-G<regex>

Look for differences whose patch text contains added / removed lines that match.

To illustrate the difference between -S<regex> --pickaxe-regex

and -G<regex>

, consider committing with the following diff in the same file:

+    return !regexec(regexp, two->ptr, 1, &regmatch, 0);
...
-    hit = !regexec(regexp, mf2.ptr, 1, &regmatch, 0);

      

Until git log -G"regexec\(regexp"

this shows, commit git log -S"regexec\(regexp" --pickaxe-regex

will not (because the number of occurrences of this line has not changed).

See the pickaxe entry in gitdiffcore [7] for more information .



For example:

git diff-tree --no-commit-id -G<regex with what you are looking at> --name-only -r bd61ad98

      

+3


source







All Articles