IndexDiff: use tree filter also for SubmoduleWalk
The only uses of IndexDiff.setFilter() in JGit and EGit set a path filter. Passing the filter on to the SubmoduleWalk gives the desired result, which is consistent with command-line git. Bug: 565251 Change-Id: I8eca1ed73eb1d237b8785f369352f72af9e0e168 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
This commit is contained in:
parent
46d58b84c9
commit
72ae234e79
|
@ -21,8 +21,10 @@
|
|||
import org.eclipse.jgit.api.errors.NoFilepatternException;
|
||||
import org.eclipse.jgit.errors.NoWorkTreeException;
|
||||
import org.eclipse.jgit.junit.RepositoryTestCase;
|
||||
import org.eclipse.jgit.lib.Repository;
|
||||
import org.eclipse.jgit.lib.Sets;
|
||||
import org.eclipse.jgit.storage.file.FileBasedConfig;
|
||||
import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
|
||||
import org.eclipse.jgit.util.FS;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -181,4 +183,31 @@ public void testFolderPrefix() throws Exception {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNestedCommittedGitRepoAndPathFilter() throws Exception {
|
||||
commitFile("file.txt", "file", "master");
|
||||
try (Repository inner = new FileRepositoryBuilder()
|
||||
.setWorkTree(new File(db.getWorkTree(), "subgit")).build()) {
|
||||
inner.create();
|
||||
writeTrashFile("subgit/sub.txt", "sub");
|
||||
try (Git outerGit = new Git(db); Git innerGit = new Git(inner)) {
|
||||
innerGit.add().addFilepattern("sub.txt").call();
|
||||
innerGit.commit().setMessage("Inner commit").call();
|
||||
outerGit.add().addFilepattern("subgit").call();
|
||||
outerGit.commit().setMessage("Outer commit").call();
|
||||
assertTrue(innerGit.status().call().isClean());
|
||||
assertTrue(outerGit.status().call().isClean());
|
||||
writeTrashFile("subgit/sub.txt", "sub2");
|
||||
assertFalse(innerGit.status().call().isClean());
|
||||
assertFalse(outerGit.status().call().isClean());
|
||||
assertTrue(
|
||||
outerGit.status().addPath("file.txt").call().isClean());
|
||||
assertTrue(outerGit.status().addPath("doesntexist").call()
|
||||
.isClean());
|
||||
assertFalse(
|
||||
outerGit.status().addPath("subgit").call().isClean());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -568,6 +568,9 @@ public boolean diff(ProgressMonitor monitor, int estWorkTreeSize,
|
|||
if (ignoreSubmoduleMode != IgnoreSubmoduleMode.ALL) {
|
||||
try (SubmoduleWalk smw = new SubmoduleWalk(repository)) {
|
||||
smw.setTree(new DirCacheIterator(dirCache));
|
||||
if (filter != null) {
|
||||
smw.setFilter(filter);
|
||||
}
|
||||
smw.setBuilderFactory(factory);
|
||||
while (smw.next()) {
|
||||
IgnoreSubmoduleMode localIgnoreSubmoduleMode = ignoreSubmoduleMode;
|
||||
|
|
Loading…
Reference in New Issue