|
|
@ -46,15 +46,15 @@ package org.eclipse.jgit.revwalk; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.IOException; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import org.eclipse.jgit.diff.DiffConfig; |
|
|
|
import org.eclipse.jgit.diff.DiffEntry; |
|
|
|
import org.eclipse.jgit.diff.DiffEntry; |
|
|
|
import org.eclipse.jgit.diff.RenameDetector; |
|
|
|
|
|
|
|
import org.eclipse.jgit.diff.DiffEntry.ChangeType; |
|
|
|
import org.eclipse.jgit.diff.DiffEntry.ChangeType; |
|
|
|
|
|
|
|
import org.eclipse.jgit.diff.RenameDetector; |
|
|
|
import org.eclipse.jgit.errors.CorruptObjectException; |
|
|
|
import org.eclipse.jgit.errors.CorruptObjectException; |
|
|
|
import org.eclipse.jgit.errors.IncorrectObjectTypeException; |
|
|
|
import org.eclipse.jgit.errors.IncorrectObjectTypeException; |
|
|
|
import org.eclipse.jgit.errors.MissingObjectException; |
|
|
|
import org.eclipse.jgit.errors.MissingObjectException; |
|
|
|
import org.eclipse.jgit.errors.StopWalkException; |
|
|
|
import org.eclipse.jgit.errors.StopWalkException; |
|
|
|
import org.eclipse.jgit.lib.ObjectId; |
|
|
|
import org.eclipse.jgit.lib.ObjectId; |
|
|
|
import org.eclipse.jgit.lib.Repository; |
|
|
|
|
|
|
|
import org.eclipse.jgit.revwalk.filter.RevFilter; |
|
|
|
import org.eclipse.jgit.revwalk.filter.RevFilter; |
|
|
|
import org.eclipse.jgit.treewalk.TreeWalk; |
|
|
|
import org.eclipse.jgit.treewalk.TreeWalk; |
|
|
|
import org.eclipse.jgit.treewalk.filter.TreeFilter; |
|
|
|
import org.eclipse.jgit.treewalk.filter.TreeFilter; |
|
|
@ -82,10 +82,7 @@ class RewriteTreeFilter extends RevFilter { |
|
|
|
|
|
|
|
|
|
|
|
private final TreeWalk pathFilter; |
|
|
|
private final TreeWalk pathFilter; |
|
|
|
|
|
|
|
|
|
|
|
private final Repository repository; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
RewriteTreeFilter(final RevWalk walker, final TreeFilter t) { |
|
|
|
RewriteTreeFilter(final RevWalk walker, final TreeFilter t) { |
|
|
|
repository = walker.repository; |
|
|
|
|
|
|
|
pathFilter = new TreeWalk(walker.reader); |
|
|
|
pathFilter = new TreeWalk(walker.reader); |
|
|
|
pathFilter.setFilter(t); |
|
|
|
pathFilter.setFilter(t); |
|
|
|
pathFilter.setRecursive(t.shouldBeRecursive()); |
|
|
|
pathFilter.setRecursive(t.shouldBeRecursive()); |
|
|
@ -142,7 +139,7 @@ class RewriteTreeFilter extends RevFilter { |
|
|
|
// commit. We need to update our filter to its older
|
|
|
|
// commit. We need to update our filter to its older
|
|
|
|
// name, if we can discover it. Find out what that is.
|
|
|
|
// name, if we can discover it. Find out what that is.
|
|
|
|
//
|
|
|
|
//
|
|
|
|
updateFollowFilter(trees); |
|
|
|
updateFollowFilter(trees, ((FollowFilter) tw.getFilter()).cfg); |
|
|
|
} |
|
|
|
} |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
@ -235,7 +232,7 @@ class RewriteTreeFilter extends RevFilter { |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void updateFollowFilter(ObjectId[] trees) |
|
|
|
private void updateFollowFilter(ObjectId[] trees, DiffConfig cfg) |
|
|
|
throws MissingObjectException, IncorrectObjectTypeException, |
|
|
|
throws MissingObjectException, IncorrectObjectTypeException, |
|
|
|
CorruptObjectException, IOException { |
|
|
|
CorruptObjectException, IOException { |
|
|
|
TreeWalk tw = pathFilter; |
|
|
|
TreeWalk tw = pathFilter; |
|
|
@ -244,14 +241,14 @@ class RewriteTreeFilter extends RevFilter { |
|
|
|
tw.reset(trees); |
|
|
|
tw.reset(trees); |
|
|
|
|
|
|
|
|
|
|
|
List<DiffEntry> files = DiffEntry.scan(tw); |
|
|
|
List<DiffEntry> files = DiffEntry.scan(tw); |
|
|
|
RenameDetector rd = new RenameDetector(repository); |
|
|
|
RenameDetector rd = new RenameDetector(tw.getObjectReader(), cfg); |
|
|
|
rd.addAll(files); |
|
|
|
rd.addAll(files); |
|
|
|
files = rd.compute(); |
|
|
|
files = rd.compute(); |
|
|
|
|
|
|
|
|
|
|
|
TreeFilter newFilter = oldFilter; |
|
|
|
TreeFilter newFilter = oldFilter; |
|
|
|
for (DiffEntry ent : files) { |
|
|
|
for (DiffEntry ent : files) { |
|
|
|
if (isRename(ent) && ent.getNewPath().equals(oldFilter.getPath())) { |
|
|
|
if (isRename(ent) && ent.getNewPath().equals(oldFilter.getPath())) { |
|
|
|
newFilter = FollowFilter.create(ent.getOldPath()); |
|
|
|
newFilter = FollowFilter.create(ent.getOldPath(), cfg); |
|
|
|
RenameCallback callback = oldFilter.getRenameCallback(); |
|
|
|
RenameCallback callback = oldFilter.getRenameCallback(); |
|
|
|
if (callback != null) { |
|
|
|
if (callback != null) { |
|
|
|
callback.renamed(ent); |
|
|
|
callback.renamed(ent); |
|
|
|