Example #1
0
  // Each of these rules are from the read-tree manpage
  // go there to see what they mean.
  // Rule 0 is left out for obvious reasons :)
  public void testRules1thru3_NoIndexEntry() throws IOException {
    GitIndex index = new GitIndex(db);

    Tree head = new Tree(db);
    FileTreeEntry headFile = head.addFile("foo");
    ObjectId objectId = ObjectId.fromString("ba78e065e2c261d4f7b8f42107588051e87e18e9");
    headFile.setId(objectId);
    Tree merge = new Tree(db);

    Checkout readTree = getCheckoutImpl(head, index, merge);
    readTree.prescanTwoTrees();

    assertTrue(readTree.removed().contains("foo"));

    readTree = getCheckoutImpl(merge, index, head);
    readTree.prescanTwoTrees();

    assertEquals(objectId, readTree.updated().get("foo"));

    ObjectId anotherId = ObjectId.fromString("ba78e065e2c261d4f7b8f42107588051e87e18ee");
    merge.addFile("foo").setId(anotherId);

    readTree = getCheckoutImpl(head, index, merge);
    readTree.prescanTwoTrees();

    assertEquals(anotherId, readTree.updated().get("foo"));
  }
Example #2
0
 private void addFileToTree(final Tree t, String filename, String content) throws IOException {
   FileTreeEntry f = t.addFile(filename);
   writeTrashFile(f.getName(), content);
   t.accept(new WriteTree(trash, db), TreeEntry.MODIFIED_ONLY);
 }