aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorThomas Wolf <thomas.wolf@paranor.ch>2020-07-17 19:41:31 +0200
committerMatthias Sohn <matthias.sohn@sap.com>2022-03-06 11:11:26 +0100
commit72ae234e79aca7f3f6a5e78e3c9c9ac6a127bba9 (patch)
tree7a5a43e614a63d492c7a36040c1bbbfc6a34b1b9 /org.eclipse.jgit.test
parent46d58b84c9170ce6021c8adfdb900b0283772829 (diff)
downloadjgit-72ae234e79aca7f3f6a5e78e3c9c9ac6a127bba9.tar.gz
jgit-72ae234e79aca7f3f6a5e78e3c9c9ac6a127bba9.zip
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>
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/api/StatusCommandTest.java29
1 files changed, 29 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/StatusCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/StatusCommandTest.java
index 5311edb0eb..19281f6c99 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/StatusCommandTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/StatusCommandTest.java
@@ -21,8 +21,10 @@ import org.eclipse.jgit.api.errors.GitAPIException;
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 class StatusCommandTest extends RepositoryTestCase {
}
}
+ @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());
+ }
+ }
+ }
+
}