Community
Participate
Working Groups
I am using difformatter.scan for git diff, Now I want to ignore diffs in pdf, png, gif , jar files. I am using `NotTreeFilter.create(PathSuffixFilter.create(".png") OR PathSuffixFilter.create(".pdf") OR so on...))` But Now, I am getting 0 file diffs for most of the commits having java files of any other valid files.
Please show real code.
``` fun computeParentChildCommitDiff(repository: Repository, childCommit: RevCommit, parentCommit: RevCommit?): List<FileDiff> { logger.info { "Computing diff between $childCommit & $parentCommit for $repository" } DiffFormatter(DisabledOutputStream.INSTANCE).use { diffFormatter -> diffFormatter.setRepository(repository) diffFormatter.pathFilter = NotTreeFilter.create(OrTreeFilter.create(listOf(PathSuffixFilter.create(".png") , PathSuffixFilter.create(".pdf")))) val diffEntries = measureTimeOfFunc({ time -> logger.info { "diffFormatter scan for $childCommit parent $parentCommit for $repository took $time ms" } }) { diffFormatter.scan(parentCommit?.tree, childCommit.tree) } logger.info { "Found diff entries ${diffEntries.size} for child $childCommit, parent $parentCommit for $repository" } if (diffEntries.size > 10_000) { logger.warn { "Skipping diff for commit $childCommit & $parentCommit as they have more than 10K file changes for $repository" } return emptyList() } val fileDiffList = diffEntries.map { convertDiffEntry(diffFormatter, it) } logger.info { "Finished computing diff entries for child $childCommit, parent $parentCommit for $repository" } return fileDiffList } } ``` This method is computing diff between parent and child, and after adding path filter , I am not getting diffs from java file too, for the same commit if i remove path filter I get diffs from java files.
Thanks, can reproduce. It's an old bug in PathSuffixFilter. A negated PathSuffixFilter, or a negation of a a logical disjunction of multiple PathSuffixFilters, skips all directories.
New Gerrit change created: https://git.eclipse.org/r/c/jgit/jgit/+/182126
When I can expect this in production?
(In reply to Pallavi Agarwal from comment #6) > When I can expect this in production? The next regular release of JGit will be in September 2021. If you need it before that, you can of course build JGit yourself once the fix is merged. Or copy the fixed PathSuffixFilter class into your own code and use that.
Gerrit change https://git.eclipse.org/r/c/jgit/jgit/+/182126 was merged to [master]. Commit: http://git.eclipse.org/c/jgit/jgit.git/commit/?id=fc57689774c5503838c96ee305f4977c585e87a2