aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorJens Baumgart <jens.baumgart@sap.com>2010-08-04 11:49:33 +0200
committerChris Aniszczyk <caniszczyk@gmail.com>2010-08-04 10:03:20 -0500
commit3ba1c7c0681642da30fce234b4a4f405852adfdd (patch)
tree3ef683b7d6f78f13c9b5a9edc10f0b87707db9ac /org.eclipse.jgit.test
parenta9c0883edec2ed5246a2dc7c046fcb3b044d0680 (diff)
downloadjgit-3ba1c7c0681642da30fce234b4a4f405852adfdd.tar.gz
jgit-3ba1c7c0681642da30fce234b4a4f405852adfdd.zip
Add gitignore support to IndexDiff and use TreeWalk
IndexDiff was re-implemented and now uses TreeWalk instead of GitIndex. Additionally, gitignore support and retrieval of untracked files was added. Change-Id: Ie6a8e04833c61d44c668c906b161202b200bb509 Signed-off-by: Jens Baumgart <jens.baumgart@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/lib/IndexDiffTest.java23
1 files changed, 17 insertions, 6 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/IndexDiffTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/IndexDiffTest.java
index ac7ce5bd48..c439baccf6 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/IndexDiffTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/IndexDiffTest.java
@@ -48,16 +48,21 @@ package org.eclipse.jgit.lib;
import java.io.File;
import java.io.IOException;
+import org.eclipse.jgit.treewalk.FileTreeIterator;
+
public class IndexDiffTest extends RepositoryTestCase {
public void testAdded() throws IOException {
GitIndex index = new GitIndex(db);
writeTrashFile("file1", "file1");
writeTrashFile("dir/subfile", "dir/subfile");
Tree tree = new Tree(db);
+ tree.setId(new ObjectWriter(db).writeTree(tree));
index.add(trash, new File(trash, "file1"));
index.add(trash, new File(trash, "dir/subfile"));
- IndexDiff diff = new IndexDiff(tree, index);
+ index.write();
+ FileTreeIterator iterator = new FileTreeIterator(db);
+ IndexDiff diff = new IndexDiff(db, tree.getId(), iterator);
diff.diff();
assertEquals(2, diff.getAdded().size());
assertTrue(diff.getAdded().contains("file1"));
@@ -68,7 +73,6 @@ public class IndexDiffTest extends RepositoryTestCase {
}
public void testRemoved() throws IOException {
- GitIndex index = new GitIndex(db);
writeTrashFile("file2", "file2");
writeTrashFile("dir/file3", "dir/file3");
@@ -82,7 +86,8 @@ public class IndexDiffTest extends RepositoryTestCase {
tree2.setId(new ObjectWriter(db).writeTree(tree2));
tree.setId(new ObjectWriter(db).writeTree(tree));
- IndexDiff diff = new IndexDiff(tree, index);
+ FileTreeIterator iterator = new FileTreeIterator(db);
+ IndexDiff diff = new IndexDiff(db, tree.getId(), iterator);
diff.diff();
assertEquals(2, diff.getRemoved().size());
assertTrue(diff.getRemoved().contains("file2"));
@@ -98,6 +103,7 @@ public class IndexDiffTest extends RepositoryTestCase {
index.add(trash, writeTrashFile("file2", "file2"));
index.add(trash, writeTrashFile("dir/file3", "dir/file3"));
+ index.write();
writeTrashFile("dir/file3", "changed");
@@ -109,7 +115,8 @@ public class IndexDiffTest extends RepositoryTestCase {
Tree tree2 = (Tree) tree.findTreeMember("dir");
tree2.setId(new ObjectWriter(db).writeTree(tree2));
tree.setId(new ObjectWriter(db).writeTree(tree));
- IndexDiff diff = new IndexDiff(tree, index);
+ FileTreeIterator iterator = new FileTreeIterator(db);
+ IndexDiff diff = new IndexDiff(db, tree.getId(), iterator);
diff.diff();
assertEquals(2, diff.getChanged().size());
assertTrue(diff.getChanged().contains("file2"));
@@ -128,6 +135,7 @@ public class IndexDiffTest extends RepositoryTestCase {
index.add(trash, writeTrashFile("a.c", "a.c"));
index.add(trash, writeTrashFile("a=c", "a=c"));
index.add(trash, writeTrashFile("a=d", "a=d"));
+ index.write();
Tree tree = new Tree(db);
// got the hash id'd from the data using echo -n a.b|git hash-object -t blob --stdin
@@ -138,7 +146,8 @@ public class IndexDiffTest extends RepositoryTestCase {
tree.setId(new ObjectWriter(db).writeTree(tree));
- IndexDiff diff = new IndexDiff(tree, index);
+ FileTreeIterator iterator = new FileTreeIterator(db);
+ IndexDiff diff = new IndexDiff(db, tree.getId(), iterator);
diff.diff();
assertEquals(0, diff.getChanged().size());
assertEquals(0, diff.getAdded().size());
@@ -163,6 +172,7 @@ public class IndexDiffTest extends RepositoryTestCase {
index.add(trash, writeTrashFile("a/c", "a/c"));
index.add(trash, writeTrashFile("a=c", "a=c"));
index.add(trash, writeTrashFile("a=d", "a=d"));
+ index.write();
Tree tree = new Tree(db);
// got the hash id'd from the data using echo -n a.b|git hash-object -t blob --stdin
@@ -180,7 +190,8 @@ public class IndexDiffTest extends RepositoryTestCase {
tree2.setId(new ObjectWriter(db).writeTree(tree2));
tree.setId(new ObjectWriter(db).writeTree(tree));
- IndexDiff diff = new IndexDiff(tree, index);
+ FileTreeIterator iterator = new FileTreeIterator(db);
+ IndexDiff diff = new IndexDiff(db, tree.getId(), iterator);
diff.diff();
assertEquals(0, diff.getChanged().size());
assertEquals(0, diff.getAdded().size());