]> source.dussan.org Git - jgit.git/commit
DiffFormatter: correctly deal with tracked files in ignored folders 83/166183/2
authorThomas Wolf <thomas.wolf@paranor.ch>
Sat, 11 Jul 2020 13:29:04 +0000 (15:29 +0200)
committerMatthias Sohn <matthias.sohn@sap.com>
Thu, 16 Jul 2020 22:50:24 +0000 (00:50 +0200)
commit533272372945e0e5ddbab1502f185c5afd582f19
tree5c48124706d65e3bb010b6168826faa6e6cc3b90
parent6206a50a46e775df90afad7292d0d264df69bf01
DiffFormatter: correctly deal with tracked files in ignored folders

In JGit 5.0, the FileTreeIterator was changed to skip ignored folders
by default. To catch tracked files inside ignored folders, the tree
walk needs to have a DirCacheIterator, and the FileTreeIterator has
to know about that DirCacheIterator via setDirCacheIterator(). (Or
the optimization has to be switched off explicitly via
setWalkIgnoredDirectories(true).)

Skipping ignored directories is an important optimization in some
cases, for instance in node.js/npm projects, where we'd otherwise
traverse the whole huge and deep hierarchy of the typically ignored
node_modules folder.

While all uses of WorkingTreeIterator in JGit had been adapted,
DiffFormatter was forgotten. To make it work correctly (again) also
for such cases, make it set up a WorkingTreeeIterator automatically,
and make sure the WorkingTreeSource can find such files, too. Also
pass the repository to the TreeWalks used inside the DiffFormatter
to pick up the correct attributes, filters, and line-ending settings.

Bug: 565081
Change-Id: Ie88ac81166dc396ba28b83313964c1712b6ca199
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/DiffFormatterTest.java
org.eclipse.jgit/src/org/eclipse/jgit/diff/ContentSource.java
org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffFormatter.java
org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java