Pull up method for creating DirCacheEntry into RepositoryTestCase
Change-Id: I6e6522289553137df1a46ceeb52f461e9d25a290
This commit is contained in:
parent
81fa566295
commit
54aceb1769
|
@ -473,4 +473,22 @@ protected RevCommit commitFile(String filename, String contents, String branch)
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected DirCacheEntry createEntry(final String path, final FileMode mode) {
|
||||||
|
return createEntry(path, mode, DirCacheEntry.STAGE_0, path);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected DirCacheEntry createEntry(final String path, final FileMode mode,
|
||||||
|
final String content) {
|
||||||
|
return createEntry(path, mode, DirCacheEntry.STAGE_0, content);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected DirCacheEntry createEntry(final String path, final FileMode mode,
|
||||||
|
final int stage, final String content) {
|
||||||
|
final DirCacheEntry entry = new DirCacheEntry(path, stage);
|
||||||
|
entry.setFileMode(mode);
|
||||||
|
entry.setObjectId(new ObjectInserter.Formatter().idFor(
|
||||||
|
Constants.OBJ_BLOB, Constants.encode(content)));
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,16 +44,13 @@
|
||||||
|
|
||||||
package org.eclipse.jgit.merge;
|
package org.eclipse.jgit.merge;
|
||||||
|
|
||||||
import static org.eclipse.jgit.lib.Constants.OBJ_BLOB;
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import org.eclipse.jgit.dircache.DirCache;
|
import org.eclipse.jgit.dircache.DirCache;
|
||||||
import org.eclipse.jgit.dircache.DirCacheBuilder;
|
import org.eclipse.jgit.dircache.DirCacheBuilder;
|
||||||
import org.eclipse.jgit.dircache.DirCacheEntry;
|
|
||||||
import org.eclipse.jgit.lib.CommitBuilder;
|
import org.eclipse.jgit.lib.CommitBuilder;
|
||||||
import org.eclipse.jgit.lib.Constants;
|
|
||||||
import org.eclipse.jgit.lib.FileMode;
|
import org.eclipse.jgit.lib.FileMode;
|
||||||
import org.eclipse.jgit.lib.ObjectId;
|
import org.eclipse.jgit.lib.ObjectId;
|
||||||
import org.eclipse.jgit.lib.ObjectInserter;
|
import org.eclipse.jgit.lib.ObjectInserter;
|
||||||
|
@ -81,16 +78,16 @@ public void testPick() throws Exception {
|
||||||
final DirCacheBuilder p = treeP.builder();
|
final DirCacheBuilder p = treeP.builder();
|
||||||
final DirCacheBuilder t = treeT.builder();
|
final DirCacheBuilder t = treeT.builder();
|
||||||
|
|
||||||
b.add(makeEntry("a", FileMode.REGULAR_FILE));
|
b.add(createEntry("a", FileMode.REGULAR_FILE));
|
||||||
|
|
||||||
o.add(makeEntry("a", FileMode.REGULAR_FILE));
|
o.add(createEntry("a", FileMode.REGULAR_FILE));
|
||||||
o.add(makeEntry("o", FileMode.REGULAR_FILE));
|
o.add(createEntry("o", FileMode.REGULAR_FILE));
|
||||||
|
|
||||||
p.add(makeEntry("a", FileMode.REGULAR_FILE, "q"));
|
p.add(createEntry("a", FileMode.REGULAR_FILE, "q"));
|
||||||
p.add(makeEntry("p-fail", FileMode.REGULAR_FILE));
|
p.add(createEntry("p-fail", FileMode.REGULAR_FILE));
|
||||||
|
|
||||||
t.add(makeEntry("a", FileMode.REGULAR_FILE));
|
t.add(createEntry("a", FileMode.REGULAR_FILE));
|
||||||
t.add(makeEntry("t", FileMode.REGULAR_FILE));
|
t.add(createEntry("t", FileMode.REGULAR_FILE));
|
||||||
|
|
||||||
b.finish();
|
b.finish();
|
||||||
o.finish();
|
o.finish();
|
||||||
|
@ -147,14 +144,14 @@ public void testRevert() throws Exception {
|
||||||
final DirCacheBuilder p = treeP.builder();
|
final DirCacheBuilder p = treeP.builder();
|
||||||
final DirCacheBuilder t = treeT.builder();
|
final DirCacheBuilder t = treeT.builder();
|
||||||
|
|
||||||
b.add(makeEntry("a", FileMode.REGULAR_FILE));
|
b.add(createEntry("a", FileMode.REGULAR_FILE));
|
||||||
|
|
||||||
p.add(makeEntry("a", FileMode.REGULAR_FILE, "q"));
|
p.add(createEntry("a", FileMode.REGULAR_FILE, "q"));
|
||||||
p.add(makeEntry("p-fail", FileMode.REGULAR_FILE));
|
p.add(createEntry("p-fail", FileMode.REGULAR_FILE));
|
||||||
|
|
||||||
t.add(makeEntry("a", FileMode.REGULAR_FILE, "q"));
|
t.add(createEntry("a", FileMode.REGULAR_FILE, "q"));
|
||||||
t.add(makeEntry("p-fail", FileMode.REGULAR_FILE));
|
t.add(createEntry("p-fail", FileMode.REGULAR_FILE));
|
||||||
t.add(makeEntry("t", FileMode.REGULAR_FILE));
|
t.add(createEntry("t", FileMode.REGULAR_FILE));
|
||||||
|
|
||||||
b.finish();
|
b.finish();
|
||||||
p.finish();
|
p.finish();
|
||||||
|
@ -203,18 +200,4 @@ private ObjectId commit(final ObjectInserter odi, final DirCache treeB,
|
||||||
odi.flush();
|
odi.flush();
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
private DirCacheEntry makeEntry(final String path, final FileMode mode)
|
|
||||||
throws Exception {
|
|
||||||
return makeEntry(path, mode, path);
|
|
||||||
}
|
|
||||||
|
|
||||||
private DirCacheEntry makeEntry(final String path, final FileMode mode,
|
|
||||||
final String content) throws Exception {
|
|
||||||
final DirCacheEntry ent = new DirCacheEntry(path);
|
|
||||||
ent.setFileMode(mode);
|
|
||||||
ent.setObjectId(new ObjectInserter.Formatter().idFor(OBJ_BLOB,
|
|
||||||
Constants.encode(content)));
|
|
||||||
return ent;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,6 @@
|
||||||
|
|
||||||
package org.eclipse.jgit.merge;
|
package org.eclipse.jgit.merge;
|
||||||
|
|
||||||
import static org.eclipse.jgit.lib.Constants.OBJ_BLOB;
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
@ -53,9 +52,7 @@
|
||||||
|
|
||||||
import org.eclipse.jgit.dircache.DirCache;
|
import org.eclipse.jgit.dircache.DirCache;
|
||||||
import org.eclipse.jgit.dircache.DirCacheBuilder;
|
import org.eclipse.jgit.dircache.DirCacheBuilder;
|
||||||
import org.eclipse.jgit.dircache.DirCacheEntry;
|
|
||||||
import org.eclipse.jgit.lib.CommitBuilder;
|
import org.eclipse.jgit.lib.CommitBuilder;
|
||||||
import org.eclipse.jgit.lib.Constants;
|
|
||||||
import org.eclipse.jgit.lib.FileMode;
|
import org.eclipse.jgit.lib.FileMode;
|
||||||
import org.eclipse.jgit.lib.ObjectId;
|
import org.eclipse.jgit.lib.ObjectId;
|
||||||
import org.eclipse.jgit.lib.ObjectInserter;
|
import org.eclipse.jgit.lib.ObjectInserter;
|
||||||
|
@ -123,15 +120,15 @@ public void testTrivialTwoWay_validSubtreeSort() throws Exception {
|
||||||
final DirCacheBuilder o = treeO.builder();
|
final DirCacheBuilder o = treeO.builder();
|
||||||
final DirCacheBuilder t = treeT.builder();
|
final DirCacheBuilder t = treeT.builder();
|
||||||
|
|
||||||
b.add(makeEntry("libelf-po/a", FileMode.REGULAR_FILE));
|
b.add(createEntry("libelf-po/a", FileMode.REGULAR_FILE));
|
||||||
b.add(makeEntry("libelf/c", FileMode.REGULAR_FILE));
|
b.add(createEntry("libelf/c", FileMode.REGULAR_FILE));
|
||||||
|
|
||||||
o.add(makeEntry("Makefile", FileMode.REGULAR_FILE));
|
o.add(createEntry("Makefile", FileMode.REGULAR_FILE));
|
||||||
o.add(makeEntry("libelf-po/a", FileMode.REGULAR_FILE));
|
o.add(createEntry("libelf-po/a", FileMode.REGULAR_FILE));
|
||||||
o.add(makeEntry("libelf/c", FileMode.REGULAR_FILE));
|
o.add(createEntry("libelf/c", FileMode.REGULAR_FILE));
|
||||||
|
|
||||||
t.add(makeEntry("libelf-po/a", FileMode.REGULAR_FILE));
|
t.add(createEntry("libelf-po/a", FileMode.REGULAR_FILE));
|
||||||
t.add(makeEntry("libelf/c", FileMode.REGULAR_FILE, "blah"));
|
t.add(createEntry("libelf/c", FileMode.REGULAR_FILE, "blah"));
|
||||||
|
|
||||||
b.finish();
|
b.finish();
|
||||||
o.finish();
|
o.finish();
|
||||||
|
@ -176,14 +173,14 @@ public void testTrivialTwoWay_concurrentSubtreeChange() throws Exception {
|
||||||
final DirCacheBuilder o = treeO.builder();
|
final DirCacheBuilder o = treeO.builder();
|
||||||
final DirCacheBuilder t = treeT.builder();
|
final DirCacheBuilder t = treeT.builder();
|
||||||
|
|
||||||
b.add(makeEntry("d/o", FileMode.REGULAR_FILE));
|
b.add(createEntry("d/o", FileMode.REGULAR_FILE));
|
||||||
b.add(makeEntry("d/t", FileMode.REGULAR_FILE));
|
b.add(createEntry("d/t", FileMode.REGULAR_FILE));
|
||||||
|
|
||||||
o.add(makeEntry("d/o", FileMode.REGULAR_FILE, "o !"));
|
o.add(createEntry("d/o", FileMode.REGULAR_FILE, "o !"));
|
||||||
o.add(makeEntry("d/t", FileMode.REGULAR_FILE));
|
o.add(createEntry("d/t", FileMode.REGULAR_FILE));
|
||||||
|
|
||||||
t.add(makeEntry("d/o", FileMode.REGULAR_FILE));
|
t.add(createEntry("d/o", FileMode.REGULAR_FILE));
|
||||||
t.add(makeEntry("d/t", FileMode.REGULAR_FILE, "t !"));
|
t.add(createEntry("d/t", FileMode.REGULAR_FILE, "t !"));
|
||||||
|
|
||||||
b.finish();
|
b.finish();
|
||||||
o.finish();
|
o.finish();
|
||||||
|
@ -224,14 +221,14 @@ public void testTrivialTwoWay_conflictSubtreeChange() throws Exception {
|
||||||
final DirCacheBuilder o = treeO.builder();
|
final DirCacheBuilder o = treeO.builder();
|
||||||
final DirCacheBuilder t = treeT.builder();
|
final DirCacheBuilder t = treeT.builder();
|
||||||
|
|
||||||
b.add(makeEntry("d/o", FileMode.REGULAR_FILE));
|
b.add(createEntry("d/o", FileMode.REGULAR_FILE));
|
||||||
b.add(makeEntry("d/t", FileMode.REGULAR_FILE));
|
b.add(createEntry("d/t", FileMode.REGULAR_FILE));
|
||||||
|
|
||||||
o.add(makeEntry("d/o", FileMode.REGULAR_FILE));
|
o.add(createEntry("d/o", FileMode.REGULAR_FILE));
|
||||||
o.add(makeEntry("d/t", FileMode.REGULAR_FILE, "o !"));
|
o.add(createEntry("d/t", FileMode.REGULAR_FILE, "o !"));
|
||||||
|
|
||||||
t.add(makeEntry("d/o", FileMode.REGULAR_FILE, "t !"));
|
t.add(createEntry("d/o", FileMode.REGULAR_FILE, "t !"));
|
||||||
t.add(makeEntry("d/t", FileMode.REGULAR_FILE, "t !"));
|
t.add(createEntry("d/t", FileMode.REGULAR_FILE, "t !"));
|
||||||
|
|
||||||
b.finish();
|
b.finish();
|
||||||
o.finish();
|
o.finish();
|
||||||
|
@ -258,13 +255,13 @@ public void testTrivialTwoWay_leftDFconflict1() throws Exception {
|
||||||
final DirCacheBuilder o = treeO.builder();
|
final DirCacheBuilder o = treeO.builder();
|
||||||
final DirCacheBuilder t = treeT.builder();
|
final DirCacheBuilder t = treeT.builder();
|
||||||
|
|
||||||
b.add(makeEntry("d/o", FileMode.REGULAR_FILE));
|
b.add(createEntry("d/o", FileMode.REGULAR_FILE));
|
||||||
b.add(makeEntry("d/t", FileMode.REGULAR_FILE));
|
b.add(createEntry("d/t", FileMode.REGULAR_FILE));
|
||||||
|
|
||||||
o.add(makeEntry("d", FileMode.REGULAR_FILE));
|
o.add(createEntry("d", FileMode.REGULAR_FILE));
|
||||||
|
|
||||||
t.add(makeEntry("d/o", FileMode.REGULAR_FILE));
|
t.add(createEntry("d/o", FileMode.REGULAR_FILE));
|
||||||
t.add(makeEntry("d/t", FileMode.REGULAR_FILE, "t !"));
|
t.add(createEntry("d/t", FileMode.REGULAR_FILE, "t !"));
|
||||||
|
|
||||||
b.finish();
|
b.finish();
|
||||||
o.finish();
|
o.finish();
|
||||||
|
@ -291,13 +288,13 @@ public void testTrivialTwoWay_rightDFconflict1() throws Exception {
|
||||||
final DirCacheBuilder o = treeO.builder();
|
final DirCacheBuilder o = treeO.builder();
|
||||||
final DirCacheBuilder t = treeT.builder();
|
final DirCacheBuilder t = treeT.builder();
|
||||||
|
|
||||||
b.add(makeEntry("d/o", FileMode.REGULAR_FILE));
|
b.add(createEntry("d/o", FileMode.REGULAR_FILE));
|
||||||
b.add(makeEntry("d/t", FileMode.REGULAR_FILE));
|
b.add(createEntry("d/t", FileMode.REGULAR_FILE));
|
||||||
|
|
||||||
o.add(makeEntry("d/o", FileMode.REGULAR_FILE));
|
o.add(createEntry("d/o", FileMode.REGULAR_FILE));
|
||||||
o.add(makeEntry("d/t", FileMode.REGULAR_FILE, "o !"));
|
o.add(createEntry("d/t", FileMode.REGULAR_FILE, "o !"));
|
||||||
|
|
||||||
t.add(makeEntry("d", FileMode.REGULAR_FILE));
|
t.add(createEntry("d", FileMode.REGULAR_FILE));
|
||||||
|
|
||||||
b.finish();
|
b.finish();
|
||||||
o.finish();
|
o.finish();
|
||||||
|
@ -324,11 +321,11 @@ public void testTrivialTwoWay_leftDFconflict2() throws Exception {
|
||||||
final DirCacheBuilder o = treeO.builder();
|
final DirCacheBuilder o = treeO.builder();
|
||||||
final DirCacheBuilder t = treeT.builder();
|
final DirCacheBuilder t = treeT.builder();
|
||||||
|
|
||||||
b.add(makeEntry("d", FileMode.REGULAR_FILE));
|
b.add(createEntry("d", FileMode.REGULAR_FILE));
|
||||||
|
|
||||||
o.add(makeEntry("d", FileMode.REGULAR_FILE, "o !"));
|
o.add(createEntry("d", FileMode.REGULAR_FILE, "o !"));
|
||||||
|
|
||||||
t.add(makeEntry("d/o", FileMode.REGULAR_FILE));
|
t.add(createEntry("d/o", FileMode.REGULAR_FILE));
|
||||||
|
|
||||||
b.finish();
|
b.finish();
|
||||||
o.finish();
|
o.finish();
|
||||||
|
@ -355,11 +352,11 @@ public void testTrivialTwoWay_rightDFconflict2() throws Exception {
|
||||||
final DirCacheBuilder o = treeO.builder();
|
final DirCacheBuilder o = treeO.builder();
|
||||||
final DirCacheBuilder t = treeT.builder();
|
final DirCacheBuilder t = treeT.builder();
|
||||||
|
|
||||||
b.add(makeEntry("d", FileMode.REGULAR_FILE));
|
b.add(createEntry("d", FileMode.REGULAR_FILE));
|
||||||
|
|
||||||
o.add(makeEntry("d/o", FileMode.REGULAR_FILE));
|
o.add(createEntry("d/o", FileMode.REGULAR_FILE));
|
||||||
|
|
||||||
t.add(makeEntry("d", FileMode.REGULAR_FILE, "t !"));
|
t.add(createEntry("d", FileMode.REGULAR_FILE, "t !"));
|
||||||
|
|
||||||
b.finish();
|
b.finish();
|
||||||
o.finish();
|
o.finish();
|
||||||
|
@ -393,18 +390,4 @@ private ObjectId commit(final ObjectInserter odi, final DirCache treeB,
|
||||||
odi.flush();
|
odi.flush();
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
private DirCacheEntry makeEntry(final String path, final FileMode mode)
|
|
||||||
throws Exception {
|
|
||||||
return makeEntry(path, mode, path);
|
|
||||||
}
|
|
||||||
|
|
||||||
private DirCacheEntry makeEntry(final String path, final FileMode mode,
|
|
||||||
final String content) throws Exception {
|
|
||||||
final DirCacheEntry ent = new DirCacheEntry(path);
|
|
||||||
ent.setFileMode(mode);
|
|
||||||
ent.setObjectId(new ObjectInserter.Formatter().idFor(OBJ_BLOB,
|
|
||||||
Constants.encode(content)));
|
|
||||||
return ent;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,6 @@
|
||||||
import org.eclipse.jgit.dircache.DirCache;
|
import org.eclipse.jgit.dircache.DirCache;
|
||||||
import org.eclipse.jgit.dircache.DirCacheBuilder;
|
import org.eclipse.jgit.dircache.DirCacheBuilder;
|
||||||
import org.eclipse.jgit.dircache.DirCacheEntry;
|
import org.eclipse.jgit.dircache.DirCacheEntry;
|
||||||
import org.eclipse.jgit.lib.Constants;
|
|
||||||
import org.eclipse.jgit.lib.FileMode;
|
import org.eclipse.jgit.lib.FileMode;
|
||||||
import org.eclipse.jgit.lib.ObjectId;
|
import org.eclipse.jgit.lib.ObjectId;
|
||||||
import org.eclipse.jgit.lib.ObjectInserter;
|
import org.eclipse.jgit.lib.ObjectInserter;
|
||||||
|
@ -65,15 +64,6 @@ public class ForPathTest extends RepositoryTestCase {
|
||||||
|
|
||||||
private static final FileMode EXECUTABLE_FILE = FileMode.EXECUTABLE_FILE;
|
private static final FileMode EXECUTABLE_FILE = FileMode.EXECUTABLE_FILE;
|
||||||
|
|
||||||
private DirCacheEntry makeEntry(final String path, final FileMode mode)
|
|
||||||
throws Exception {
|
|
||||||
final DirCacheEntry ent = new DirCacheEntry(path);
|
|
||||||
ent.setFileMode(mode);
|
|
||||||
ent.setObjectId(new ObjectInserter.Formatter().idFor(
|
|
||||||
Constants.OBJ_BLOB, Constants.encode(path)));
|
|
||||||
return ent;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFindObjects() throws Exception {
|
public void testFindObjects() throws Exception {
|
||||||
final DirCache tree0 = DirCache.newInCore();
|
final DirCache tree0 = DirCache.newInCore();
|
||||||
|
@ -81,13 +71,13 @@ public void testFindObjects() throws Exception {
|
||||||
ObjectReader or = db.newObjectReader();
|
ObjectReader or = db.newObjectReader();
|
||||||
ObjectInserter oi = db.newObjectInserter();
|
ObjectInserter oi = db.newObjectInserter();
|
||||||
|
|
||||||
DirCacheEntry aDotB = makeEntry("a.b", EXECUTABLE_FILE);
|
DirCacheEntry aDotB = createEntry("a.b", EXECUTABLE_FILE);
|
||||||
b0.add(aDotB);
|
b0.add(aDotB);
|
||||||
DirCacheEntry aSlashB = makeEntry("a/b", REGULAR_FILE);
|
DirCacheEntry aSlashB = createEntry("a/b", REGULAR_FILE);
|
||||||
b0.add(aSlashB);
|
b0.add(aSlashB);
|
||||||
DirCacheEntry aSlashCSlashD = makeEntry("a/c/d", REGULAR_FILE);
|
DirCacheEntry aSlashCSlashD = createEntry("a/c/d", REGULAR_FILE);
|
||||||
b0.add(aSlashCSlashD);
|
b0.add(aSlashCSlashD);
|
||||||
DirCacheEntry aZeroB = makeEntry("a0b", SYMLINK);
|
DirCacheEntry aZeroB = createEntry("a0b", SYMLINK);
|
||||||
b0.add(aZeroB);
|
b0.add(aZeroB);
|
||||||
b0.finish();
|
b0.finish();
|
||||||
assertEquals(4, tree0.getEntryCount());
|
assertEquals(4, tree0.getEntryCount());
|
||||||
|
|
|
@ -49,11 +49,8 @@
|
||||||
|
|
||||||
import org.eclipse.jgit.dircache.DirCache;
|
import org.eclipse.jgit.dircache.DirCache;
|
||||||
import org.eclipse.jgit.dircache.DirCacheBuilder;
|
import org.eclipse.jgit.dircache.DirCacheBuilder;
|
||||||
import org.eclipse.jgit.dircache.DirCacheEntry;
|
|
||||||
import org.eclipse.jgit.dircache.DirCacheIterator;
|
import org.eclipse.jgit.dircache.DirCacheIterator;
|
||||||
import org.eclipse.jgit.lib.Constants;
|
|
||||||
import org.eclipse.jgit.lib.FileMode;
|
import org.eclipse.jgit.lib.FileMode;
|
||||||
import org.eclipse.jgit.lib.ObjectInserter;
|
|
||||||
import org.eclipse.jgit.lib.RepositoryTestCase;
|
import org.eclipse.jgit.lib.RepositoryTestCase;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
@ -76,10 +73,10 @@ public void testNoDF_NoGap() throws Exception {
|
||||||
final DirCacheBuilder b0 = tree0.builder();
|
final DirCacheBuilder b0 = tree0.builder();
|
||||||
final DirCacheBuilder b1 = tree1.builder();
|
final DirCacheBuilder b1 = tree1.builder();
|
||||||
|
|
||||||
b0.add(makeEntry("a", REGULAR_FILE));
|
b0.add(createEntry("a", REGULAR_FILE));
|
||||||
b0.add(makeEntry("a.b", EXECUTABLE_FILE));
|
b0.add(createEntry("a.b", EXECUTABLE_FILE));
|
||||||
b1.add(makeEntry("a/b", REGULAR_FILE));
|
b1.add(createEntry("a/b", REGULAR_FILE));
|
||||||
b0.add(makeEntry("a0b", SYMLINK));
|
b0.add(createEntry("a0b", SYMLINK));
|
||||||
|
|
||||||
b0.finish();
|
b0.finish();
|
||||||
b1.finish();
|
b1.finish();
|
||||||
|
@ -107,10 +104,10 @@ public void testDF_NoGap() throws Exception {
|
||||||
final DirCacheBuilder b0 = tree0.builder();
|
final DirCacheBuilder b0 = tree0.builder();
|
||||||
final DirCacheBuilder b1 = tree1.builder();
|
final DirCacheBuilder b1 = tree1.builder();
|
||||||
|
|
||||||
b0.add(makeEntry("a", REGULAR_FILE));
|
b0.add(createEntry("a", REGULAR_FILE));
|
||||||
b0.add(makeEntry("a.b", EXECUTABLE_FILE));
|
b0.add(createEntry("a.b", EXECUTABLE_FILE));
|
||||||
b1.add(makeEntry("a/b", REGULAR_FILE));
|
b1.add(createEntry("a/b", REGULAR_FILE));
|
||||||
b0.add(makeEntry("a0b", SYMLINK));
|
b0.add(createEntry("a0b", SYMLINK));
|
||||||
|
|
||||||
b0.finish();
|
b0.finish();
|
||||||
b1.finish();
|
b1.finish();
|
||||||
|
@ -142,11 +139,11 @@ public void testDF_GapByOne() throws Exception {
|
||||||
final DirCacheBuilder b0 = tree0.builder();
|
final DirCacheBuilder b0 = tree0.builder();
|
||||||
final DirCacheBuilder b1 = tree1.builder();
|
final DirCacheBuilder b1 = tree1.builder();
|
||||||
|
|
||||||
b0.add(makeEntry("a", REGULAR_FILE));
|
b0.add(createEntry("a", REGULAR_FILE));
|
||||||
b0.add(makeEntry("a.b", EXECUTABLE_FILE));
|
b0.add(createEntry("a.b", EXECUTABLE_FILE));
|
||||||
b1.add(makeEntry("a.b", EXECUTABLE_FILE));
|
b1.add(createEntry("a.b", EXECUTABLE_FILE));
|
||||||
b1.add(makeEntry("a/b", REGULAR_FILE));
|
b1.add(createEntry("a/b", REGULAR_FILE));
|
||||||
b0.add(makeEntry("a0b", SYMLINK));
|
b0.add(createEntry("a0b", SYMLINK));
|
||||||
|
|
||||||
b0.finish();
|
b0.finish();
|
||||||
b1.finish();
|
b1.finish();
|
||||||
|
@ -178,11 +175,11 @@ public void testDF_SkipsSeenSubtree() throws Exception {
|
||||||
final DirCacheBuilder b0 = tree0.builder();
|
final DirCacheBuilder b0 = tree0.builder();
|
||||||
final DirCacheBuilder b1 = tree1.builder();
|
final DirCacheBuilder b1 = tree1.builder();
|
||||||
|
|
||||||
b0.add(makeEntry("a", REGULAR_FILE));
|
b0.add(createEntry("a", REGULAR_FILE));
|
||||||
b1.add(makeEntry("a.b", EXECUTABLE_FILE));
|
b1.add(createEntry("a.b", EXECUTABLE_FILE));
|
||||||
b1.add(makeEntry("a/b", REGULAR_FILE));
|
b1.add(createEntry("a/b", REGULAR_FILE));
|
||||||
b0.add(makeEntry("a0b", SYMLINK));
|
b0.add(createEntry("a0b", SYMLINK));
|
||||||
b1.add(makeEntry("a0b", SYMLINK));
|
b1.add(createEntry("a0b", SYMLINK));
|
||||||
|
|
||||||
b0.finish();
|
b0.finish();
|
||||||
b1.finish();
|
b1.finish();
|
||||||
|
@ -214,12 +211,12 @@ public void testDF_DetectConflict() throws Exception {
|
||||||
final DirCacheBuilder b0 = tree0.builder();
|
final DirCacheBuilder b0 = tree0.builder();
|
||||||
final DirCacheBuilder b1 = tree1.builder();
|
final DirCacheBuilder b1 = tree1.builder();
|
||||||
|
|
||||||
b0.add(makeEntry("0", REGULAR_FILE));
|
b0.add(createEntry("0", REGULAR_FILE));
|
||||||
b0.add(makeEntry("a", REGULAR_FILE));
|
b0.add(createEntry("a", REGULAR_FILE));
|
||||||
b1.add(makeEntry("0", REGULAR_FILE));
|
b1.add(createEntry("0", REGULAR_FILE));
|
||||||
b1.add(makeEntry("a.b", REGULAR_FILE));
|
b1.add(createEntry("a.b", REGULAR_FILE));
|
||||||
b1.add(makeEntry("a/b", REGULAR_FILE));
|
b1.add(createEntry("a/b", REGULAR_FILE));
|
||||||
b1.add(makeEntry("a/c/e", REGULAR_FILE));
|
b1.add(createEntry("a/c/e", REGULAR_FILE));
|
||||||
|
|
||||||
b0.finish();
|
b0.finish();
|
||||||
b1.finish();
|
b1.finish();
|
||||||
|
@ -249,15 +246,6 @@ public void testDF_DetectConflict() throws Exception {
|
||||||
assertFalse(tw.isDirectoryFileConflict());
|
assertFalse(tw.isDirectoryFileConflict());
|
||||||
}
|
}
|
||||||
|
|
||||||
private DirCacheEntry makeEntry(final String path, final FileMode mode)
|
|
||||||
throws Exception {
|
|
||||||
final DirCacheEntry ent = new DirCacheEntry(path);
|
|
||||||
ent.setFileMode(mode);
|
|
||||||
ent.setObjectId(new ObjectInserter.Formatter().idFor(
|
|
||||||
Constants.OBJ_BLOB, Constants.encode(path)));
|
|
||||||
return ent;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void assertModes(final String path, final FileMode mode0,
|
private static void assertModes(final String path, final FileMode mode0,
|
||||||
final FileMode mode1, final TreeWalk tw) throws Exception {
|
final FileMode mode1, final TreeWalk tw) throws Exception {
|
||||||
assertTrue("has " + path, tw.next());
|
assertTrue("has " + path, tw.next());
|
||||||
|
|
|
@ -53,9 +53,7 @@
|
||||||
import org.eclipse.jgit.dircache.DirCacheBuilder;
|
import org.eclipse.jgit.dircache.DirCacheBuilder;
|
||||||
import org.eclipse.jgit.dircache.DirCacheEntry;
|
import org.eclipse.jgit.dircache.DirCacheEntry;
|
||||||
import org.eclipse.jgit.dircache.DirCacheIterator;
|
import org.eclipse.jgit.dircache.DirCacheIterator;
|
||||||
import org.eclipse.jgit.lib.Constants;
|
|
||||||
import org.eclipse.jgit.lib.FileMode;
|
import org.eclipse.jgit.lib.FileMode;
|
||||||
import org.eclipse.jgit.lib.ObjectInserter;
|
|
||||||
import org.eclipse.jgit.lib.RepositoryTestCase;
|
import org.eclipse.jgit.lib.RepositoryTestCase;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
@ -183,11 +181,7 @@ public void testWithPostOrder_NoEnterSubtree() throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
private DirCacheEntry makeFile(final String path) throws Exception {
|
private DirCacheEntry makeFile(final String path) throws Exception {
|
||||||
final DirCacheEntry ent = new DirCacheEntry(path);
|
return createEntry(path, REGULAR_FILE);
|
||||||
ent.setFileMode(REGULAR_FILE);
|
|
||||||
ent.setObjectId(new ObjectInserter.Formatter().idFor(
|
|
||||||
Constants.OBJ_BLOB, Constants.encode(path)));
|
|
||||||
return ent;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void assertModes(final String path, final FileMode mode0,
|
private static void assertModes(final String path, final FileMode mode0,
|
||||||
|
|
Loading…
Reference in New Issue