Package org.eclipse.jgit.lib

Examples of org.eclipse.jgit.lib.RefUpdate.update()


  @Test
  public void testUpdateRefNoChange() throws IOException {
    ObjectId pid = db.resolve("refs/heads/master");
    RefUpdate updateRef = db.updateRef("refs/heads/master");
    updateRef.setNewObjectId(pid);
    Result update = updateRef.update();
    assertEquals(Result.NO_CHANGE, update);
    assertEquals(pid, db.resolve("refs/heads/master"));
  }

  /**
 
View Full Code Here


    ObjectId newValue = db.resolve("HEAD^");
    // first make HEAD refer to loose ref
    RefUpdate updateRef = db.updateRef(Constants.HEAD);
    updateRef.setForceUpdate(true);
    updateRef.setNewObjectId(newValue);
    Result update = updateRef.update();
    assertEquals(Result.FORCED, update);

    // now update that ref
    updateRef = db.updateRef(Constants.HEAD);
    updateRef.setNewObjectId(oldValue);
View Full Code Here

    assertEquals(Result.FORCED, update);

    // now update that ref
    updateRef = db.updateRef(Constants.HEAD);
    updateRef.setNewObjectId(oldValue);
    update = updateRef.update();
    assertEquals(Result.FAST_FORWARD, update);

    allRefs = db.getAllRefs();
    Ref master = allRefs.get("refs/heads/master");
    Ref head = allRefs.get("HEAD");
View Full Code Here

    ObjectId oldValue = db.resolve("HEAD");
    writeSymref(Constants.HEAD, "refs/heads/newref");
    RefUpdate updateRef = db.updateRef(Constants.HEAD);
    updateRef.setForceUpdate(true);
    updateRef.setNewObjectId(oldValue);
    Result update = updateRef.update();
    assertEquals(Result.NEW, update);

    allRefs = db.getAllRefs();
    Ref head = allRefs.get("HEAD");
    Ref newref = allRefs.get("refs/heads/newref");
View Full Code Here

  public void testUpdateRefLockFailureWrongOldValue() throws IOException {
    ObjectId pid = db.resolve("refs/heads/master");
    RefUpdate updateRef = db.updateRef("refs/heads/master");
    updateRef.setNewObjectId(pid);
    updateRef.setExpectedOldObjectId(db.resolve("refs/heads/master^"));
    Result update = updateRef.update();
    assertEquals(Result.LOCK_FAILURE, update);
    assertEquals(pid, db.resolve("refs/heads/master"));
  }

  /**
 
View Full Code Here

    ObjectId pid = db.resolve("refs/heads/master");

    RefUpdate updateRef = db.updateRef("refs/heads/master");
    updateRef.setNewObjectId(ppid);
    updateRef.setForceUpdate(true);
    Result update = updateRef.update();
    assertEquals(Result.FORCED, update);
    assertEquals(ppid, db.resolve("refs/heads/master"));

    // real test
    RefUpdate updateRef2 = db.updateRef("refs/heads/master");
View Full Code Here

    // real test
    RefUpdate updateRef2 = db.updateRef("refs/heads/master");
    updateRef2.setExpectedOldObjectId(ppid);
    updateRef2.setNewObjectId(pid);
    Result update2 = updateRef2.update();
    assertEquals(Result.FAST_FORWARD, update2);
    assertEquals(pid, db.resolve("refs/heads/master"));
  }

  /**
 
View Full Code Here

    ObjectId pid = db.resolve("refs/heads/master");

    RefUpdate updateRef = db.updateRef("refs/heads/master");
    updateRef.setNewObjectId(ppid);
    updateRef.setForceUpdate(true);
    Result update = updateRef.update();
    assertEquals(Result.FORCED, update);
    assertEquals(ppid, db.resolve("refs/heads/master"));

    // real test
    RevCommit old = new RevWalk(db).parseCommit(ppid);
View Full Code Here

    // real test
    RevCommit old = new RevWalk(db).parseCommit(ppid);
    RefUpdate updateRef2 = db.updateRef("refs/heads/master");
    updateRef2.setExpectedOldObjectId(old);
    updateRef2.setNewObjectId(pid);
    Result update2 = updateRef2.update();
    assertEquals(Result.FAST_FORWARD, update2);
    assertEquals(pid, db.resolve("refs/heads/master"));
  }

  /**
 
View Full Code Here

    updateRef.setNewObjectId(pid);
    LockFile lockFile1 = new LockFile(new File(db.getDirectory(),
        "refs/heads/master"), db.getFS());
    try {
      assertTrue(lockFile1.lock()); // precondition to test
      Result update = updateRef.update();
      assertEquals(Result.LOCK_FAILURE, update);
      assertEquals(opid, db.resolve("refs/heads/master"));
      LockFile lockFile2 = new LockFile(new File(db.getDirectory(),"refs/heads/master"),
          db.getFS());
      assertFalse(lockFile2.lock()); // was locked, still is
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.