Git > diffs filtered, show only certain changed classes/files

1.1k views Asked by At

I have 2 versions of a software (i.e. tag 4.1 and tag 4.2).

Now I want to filter out in which java classes of version 4.1 there were fixed bugs.

If I enter git diff r4.1 r4.2 --name-only > patch.csv I get a list of all changed classes from version 4.1 to 4.2. But this list also consists changes that were not based on a bug.

Is there a possibility that I can filter the result in order to only display classes which were changed because of a commit which contained the word "bug". In example "git log --grep=bug". Can I combine this with the "diff" command?

If this is not possible it would also be fine to me when I just look at the version 4.2 and get a list of changed classes that result from fixing a bug.

something like this git r4.2 log --grep=bug --name-only?

1

There are 1 answers

5
Mureinik On BEST ANSWER

git log r4.1..r4.2 --name-only --grep=bug --pretty=oneline should give you a list of commit message headers and the files changed in them without the commit message itself. You could then redirect the output to get an easy to read list of classes:

$ git log r4.1..r4.2 --name-only --grep=bug --pretty=oneline | grep "\.java$" | sort | uniq