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;
+ }
}
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.assertFalse;
import static org.junit.Assert.assertTrue;
import org.eclipse.jgit.dircache.DirCache;
import org.eclipse.jgit.dircache.DirCacheBuilder;
-import org.eclipse.jgit.dircache.DirCacheEntry;
import org.eclipse.jgit.lib.CommitBuilder;
-import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.FileMode;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.ObjectInserter;
final DirCacheBuilder p = treeP.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(makeEntry("o", FileMode.REGULAR_FILE));
+ o.add(createEntry("a", FileMode.REGULAR_FILE));
+ o.add(createEntry("o", FileMode.REGULAR_FILE));
- p.add(makeEntry("a", FileMode.REGULAR_FILE, "q"));
- p.add(makeEntry("p-fail", FileMode.REGULAR_FILE));
+ p.add(createEntry("a", FileMode.REGULAR_FILE, "q"));
+ p.add(createEntry("p-fail", FileMode.REGULAR_FILE));
- t.add(makeEntry("a", FileMode.REGULAR_FILE));
- t.add(makeEntry("t", FileMode.REGULAR_FILE));
+ t.add(createEntry("a", FileMode.REGULAR_FILE));
+ t.add(createEntry("t", FileMode.REGULAR_FILE));
b.finish();
o.finish();
final DirCacheBuilder p = treeP.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(makeEntry("p-fail", FileMode.REGULAR_FILE));
+ p.add(createEntry("a", FileMode.REGULAR_FILE, "q"));
+ p.add(createEntry("p-fail", FileMode.REGULAR_FILE));
- t.add(makeEntry("a", FileMode.REGULAR_FILE, "q"));
- t.add(makeEntry("p-fail", FileMode.REGULAR_FILE));
- t.add(makeEntry("t", FileMode.REGULAR_FILE));
+ t.add(createEntry("a", FileMode.REGULAR_FILE, "q"));
+ t.add(createEntry("p-fail", FileMode.REGULAR_FILE));
+ t.add(createEntry("t", FileMode.REGULAR_FILE));
b.finish();
p.finish();
odi.flush();
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;
- }
}
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.assertFalse;
import static org.junit.Assert.assertTrue;
import org.eclipse.jgit.dircache.DirCache;
import org.eclipse.jgit.dircache.DirCacheBuilder;
-import org.eclipse.jgit.dircache.DirCacheEntry;
import org.eclipse.jgit.lib.CommitBuilder;
-import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.FileMode;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.ObjectInserter;
final DirCacheBuilder o = treeO.builder();
final DirCacheBuilder t = treeT.builder();
- b.add(makeEntry("libelf-po/a", FileMode.REGULAR_FILE));
- b.add(makeEntry("libelf/c", FileMode.REGULAR_FILE));
+ b.add(createEntry("libelf-po/a", FileMode.REGULAR_FILE));
+ b.add(createEntry("libelf/c", FileMode.REGULAR_FILE));
- o.add(makeEntry("Makefile", FileMode.REGULAR_FILE));
- o.add(makeEntry("libelf-po/a", FileMode.REGULAR_FILE));
- o.add(makeEntry("libelf/c", FileMode.REGULAR_FILE));
+ o.add(createEntry("Makefile", FileMode.REGULAR_FILE));
+ o.add(createEntry("libelf-po/a", FileMode.REGULAR_FILE));
+ o.add(createEntry("libelf/c", FileMode.REGULAR_FILE));
- t.add(makeEntry("libelf-po/a", FileMode.REGULAR_FILE));
- t.add(makeEntry("libelf/c", FileMode.REGULAR_FILE, "blah"));
+ t.add(createEntry("libelf-po/a", FileMode.REGULAR_FILE));
+ t.add(createEntry("libelf/c", FileMode.REGULAR_FILE, "blah"));
b.finish();
o.finish();
final DirCacheBuilder o = treeO.builder();
final DirCacheBuilder t = treeT.builder();
- b.add(makeEntry("d/o", FileMode.REGULAR_FILE));
- b.add(makeEntry("d/t", FileMode.REGULAR_FILE));
+ b.add(createEntry("d/o", FileMode.REGULAR_FILE));
+ b.add(createEntry("d/t", FileMode.REGULAR_FILE));
- o.add(makeEntry("d/o", FileMode.REGULAR_FILE, "o !"));
- o.add(makeEntry("d/t", FileMode.REGULAR_FILE));
+ o.add(createEntry("d/o", FileMode.REGULAR_FILE, "o !"));
+ o.add(createEntry("d/t", FileMode.REGULAR_FILE));
- t.add(makeEntry("d/o", FileMode.REGULAR_FILE));
- t.add(makeEntry("d/t", FileMode.REGULAR_FILE, "t !"));
+ t.add(createEntry("d/o", FileMode.REGULAR_FILE));
+ t.add(createEntry("d/t", FileMode.REGULAR_FILE, "t !"));
b.finish();
o.finish();
final DirCacheBuilder o = treeO.builder();
final DirCacheBuilder t = treeT.builder();
- b.add(makeEntry("d/o", FileMode.REGULAR_FILE));
- b.add(makeEntry("d/t", FileMode.REGULAR_FILE));
+ b.add(createEntry("d/o", FileMode.REGULAR_FILE));
+ b.add(createEntry("d/t", FileMode.REGULAR_FILE));
- o.add(makeEntry("d/o", FileMode.REGULAR_FILE));
- o.add(makeEntry("d/t", FileMode.REGULAR_FILE, "o !"));
+ o.add(createEntry("d/o", FileMode.REGULAR_FILE));
+ o.add(createEntry("d/t", FileMode.REGULAR_FILE, "o !"));
- t.add(makeEntry("d/o", FileMode.REGULAR_FILE, "t !"));
- t.add(makeEntry("d/t", FileMode.REGULAR_FILE, "t !"));
+ t.add(createEntry("d/o", FileMode.REGULAR_FILE, "t !"));
+ t.add(createEntry("d/t", FileMode.REGULAR_FILE, "t !"));
b.finish();
o.finish();
final DirCacheBuilder o = treeO.builder();
final DirCacheBuilder t = treeT.builder();
- b.add(makeEntry("d/o", FileMode.REGULAR_FILE));
- b.add(makeEntry("d/t", FileMode.REGULAR_FILE));
+ b.add(createEntry("d/o", 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(makeEntry("d/t", FileMode.REGULAR_FILE, "t !"));
+ t.add(createEntry("d/o", FileMode.REGULAR_FILE));
+ t.add(createEntry("d/t", FileMode.REGULAR_FILE, "t !"));
b.finish();
o.finish();
final DirCacheBuilder o = treeO.builder();
final DirCacheBuilder t = treeT.builder();
- b.add(makeEntry("d/o", FileMode.REGULAR_FILE));
- b.add(makeEntry("d/t", FileMode.REGULAR_FILE));
+ b.add(createEntry("d/o", FileMode.REGULAR_FILE));
+ b.add(createEntry("d/t", FileMode.REGULAR_FILE));
- o.add(makeEntry("d/o", FileMode.REGULAR_FILE));
- o.add(makeEntry("d/t", FileMode.REGULAR_FILE, "o !"));
+ o.add(createEntry("d/o", FileMode.REGULAR_FILE));
+ 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();
o.finish();
final DirCacheBuilder o = treeO.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();
o.finish();
final DirCacheBuilder o = treeO.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();
o.finish();
odi.flush();
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;
- }
}
import org.eclipse.jgit.dircache.DirCache;
import org.eclipse.jgit.dircache.DirCacheBuilder;
import org.eclipse.jgit.dircache.DirCacheEntry;
-import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.FileMode;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.ObjectInserter;
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
public void testFindObjects() throws Exception {
final DirCache tree0 = DirCache.newInCore();
ObjectReader or = db.newObjectReader();
ObjectInserter oi = db.newObjectInserter();
- DirCacheEntry aDotB = makeEntry("a.b", EXECUTABLE_FILE);
+ DirCacheEntry aDotB = createEntry("a.b", EXECUTABLE_FILE);
b0.add(aDotB);
- DirCacheEntry aSlashB = makeEntry("a/b", REGULAR_FILE);
+ DirCacheEntry aSlashB = createEntry("a/b", REGULAR_FILE);
b0.add(aSlashB);
- DirCacheEntry aSlashCSlashD = makeEntry("a/c/d", REGULAR_FILE);
+ DirCacheEntry aSlashCSlashD = createEntry("a/c/d", REGULAR_FILE);
b0.add(aSlashCSlashD);
- DirCacheEntry aZeroB = makeEntry("a0b", SYMLINK);
+ DirCacheEntry aZeroB = createEntry("a0b", SYMLINK);
b0.add(aZeroB);
b0.finish();
assertEquals(4, tree0.getEntryCount());
import org.eclipse.jgit.dircache.DirCache;
import org.eclipse.jgit.dircache.DirCacheBuilder;
-import org.eclipse.jgit.dircache.DirCacheEntry;
import org.eclipse.jgit.dircache.DirCacheIterator;
-import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.FileMode;
-import org.eclipse.jgit.lib.ObjectInserter;
import org.eclipse.jgit.lib.RepositoryTestCase;
import org.junit.Test;
final DirCacheBuilder b0 = tree0.builder();
final DirCacheBuilder b1 = tree1.builder();
- b0.add(makeEntry("a", REGULAR_FILE));
- b0.add(makeEntry("a.b", EXECUTABLE_FILE));
- b1.add(makeEntry("a/b", REGULAR_FILE));
- b0.add(makeEntry("a0b", SYMLINK));
+ b0.add(createEntry("a", REGULAR_FILE));
+ b0.add(createEntry("a.b", EXECUTABLE_FILE));
+ b1.add(createEntry("a/b", REGULAR_FILE));
+ b0.add(createEntry("a0b", SYMLINK));
b0.finish();
b1.finish();
final DirCacheBuilder b0 = tree0.builder();
final DirCacheBuilder b1 = tree1.builder();
- b0.add(makeEntry("a", REGULAR_FILE));
- b0.add(makeEntry("a.b", EXECUTABLE_FILE));
- b1.add(makeEntry("a/b", REGULAR_FILE));
- b0.add(makeEntry("a0b", SYMLINK));
+ b0.add(createEntry("a", REGULAR_FILE));
+ b0.add(createEntry("a.b", EXECUTABLE_FILE));
+ b1.add(createEntry("a/b", REGULAR_FILE));
+ b0.add(createEntry("a0b", SYMLINK));
b0.finish();
b1.finish();
final DirCacheBuilder b0 = tree0.builder();
final DirCacheBuilder b1 = tree1.builder();
- b0.add(makeEntry("a", REGULAR_FILE));
- b0.add(makeEntry("a.b", EXECUTABLE_FILE));
- b1.add(makeEntry("a.b", EXECUTABLE_FILE));
- b1.add(makeEntry("a/b", REGULAR_FILE));
- b0.add(makeEntry("a0b", SYMLINK));
+ b0.add(createEntry("a", REGULAR_FILE));
+ b0.add(createEntry("a.b", EXECUTABLE_FILE));
+ b1.add(createEntry("a.b", EXECUTABLE_FILE));
+ b1.add(createEntry("a/b", REGULAR_FILE));
+ b0.add(createEntry("a0b", SYMLINK));
b0.finish();
b1.finish();
final DirCacheBuilder b0 = tree0.builder();
final DirCacheBuilder b1 = tree1.builder();
- b0.add(makeEntry("a", REGULAR_FILE));
- b1.add(makeEntry("a.b", EXECUTABLE_FILE));
- b1.add(makeEntry("a/b", REGULAR_FILE));
- b0.add(makeEntry("a0b", SYMLINK));
- b1.add(makeEntry("a0b", SYMLINK));
+ b0.add(createEntry("a", REGULAR_FILE));
+ b1.add(createEntry("a.b", EXECUTABLE_FILE));
+ b1.add(createEntry("a/b", REGULAR_FILE));
+ b0.add(createEntry("a0b", SYMLINK));
+ b1.add(createEntry("a0b", SYMLINK));
b0.finish();
b1.finish();
final DirCacheBuilder b0 = tree0.builder();
final DirCacheBuilder b1 = tree1.builder();
- b0.add(makeEntry("0", REGULAR_FILE));
- b0.add(makeEntry("a", REGULAR_FILE));
- b1.add(makeEntry("0", REGULAR_FILE));
- b1.add(makeEntry("a.b", REGULAR_FILE));
- b1.add(makeEntry("a/b", REGULAR_FILE));
- b1.add(makeEntry("a/c/e", REGULAR_FILE));
+ b0.add(createEntry("0", REGULAR_FILE));
+ b0.add(createEntry("a", REGULAR_FILE));
+ b1.add(createEntry("0", REGULAR_FILE));
+ b1.add(createEntry("a.b", REGULAR_FILE));
+ b1.add(createEntry("a/b", REGULAR_FILE));
+ b1.add(createEntry("a/c/e", REGULAR_FILE));
b0.finish();
b1.finish();
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,
final FileMode mode1, final TreeWalk tw) throws Exception {
assertTrue("has " + path, tw.next());
import org.eclipse.jgit.dircache.DirCacheBuilder;
import org.eclipse.jgit.dircache.DirCacheEntry;
import org.eclipse.jgit.dircache.DirCacheIterator;
-import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.FileMode;
-import org.eclipse.jgit.lib.ObjectInserter;
import org.eclipse.jgit.lib.RepositoryTestCase;
import org.junit.Test;
}
private DirCacheEntry makeFile(final String path) throws Exception {
- final DirCacheEntry ent = new DirCacheEntry(path);
- ent.setFileMode(REGULAR_FILE);
- ent.setObjectId(new ObjectInserter.Formatter().idFor(
- Constants.OBJ_BLOB, Constants.encode(path)));
- return ent;
+ return createEntry(path, REGULAR_FILE);
}
private static void assertModes(final String path, final FileMode mode0,