Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 368
Harald Foidl Avatar asked Feb 28 '26 00:02

Harald Foidl


1 Answers

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
like image 148
Mureinik Avatar answered Mar 02 '26 15:03

Mureinik



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!