diff options
author | Christian Halstrick <christian.halstrick@sap.com> | 2013-07-19 13:37:58 +0200 |
---|---|---|
committer | Chris Aniszczyk <caniszczyk@gmail.com> | 2013-07-21 21:39:53 -0500 |
commit | 06dd0e9e27a342f74ec97648ab1fbf101af383a4 (patch) | |
tree | 0b1235cca24e9b048be7b727893a94d4aca527bf /org.eclipse.jgit.test | |
parent | f5be93d003759f6c933d33d56c8a18fa9e66766b (diff) | |
download | jgit-06dd0e9e27a342f74ec97648ab1fbf101af383a4.tar.gz jgit-06dd0e9e27a342f74ec97648ab1fbf101af383a4.zip |
Add path option to StatusCommand
Allow filtering of the status. Only files which match given paths are
inspected and only their state is reported.
Change-Id: I3c4b1b46bf297cd4ebdb4997cfa14c8752a36411
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/api/StatusCommandTest.java | 36 |
1 files changed, 36 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 e98263a2ac..8b3e87f2dc 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 @@ -132,6 +132,42 @@ public class StatusCommandTest extends RepositoryTestCase { assertTrue(stat.getUntrackedFolders().contains("sub")); } + @Test + public void testDifferentStatesWithPaths() throws IOException, + NoFilepatternException, GitAPIException { + Git git = new Git(db); + writeTrashFile("a", "content of a"); + writeTrashFile("D/b", "content of b"); + writeTrashFile("D/c", "content of c"); + writeTrashFile("D/D/d", "content of d"); + git.add().addFilepattern(".").call(); + + writeTrashFile("a", "new content of a"); + writeTrashFile("D/b", "new content of b"); + writeTrashFile("D/D/d", "new content of d"); + + + // filter on an not existing path + Status stat = git.status().addPath("x").call(); + assertEquals(0, stat.getModified().size()); + + // filter on an existing file + stat = git.status().addPath("a").call(); + assertEquals(set("a"), stat.getModified()); + + // filter on an existing folder + stat = git.status().addPath("D").call(); + assertEquals(set("D/b", "D/D/d"), stat.getModified()); + + // filter on an existing folder and file + stat = git.status().addPath("D/D").addPath("a").call(); + assertEquals(set("a", "D/D/d"), stat.getModified()); + + // do not filter at all + stat = git.status().call(); + assertEquals(set("a", "D/b", "D/D/d"), stat.getModified()); + } + public static Set<String> set(String... elements) { Set<String> ret = new HashSet<String>(); for (String element : elements) |