Merge test will be performed according to {@link #isForceUpdate()}.
This is the same as:
return update(new RevWalk(getRepository()));
184185186187188189190191192193194
@Test public void testNewNamespaceConflictWithPackedPrefixOfExisting() throws IOException { final String newRef = "refs/heads/prefix"; final RefUpdate ru = updateRef(newRef); Result update = ru.update(); assertEquals(Result.LOCK_FAILURE, update); assertNull(db.getReflogReader("refs/heads/prefix")); assertEquals(0, db.getReflogReader("HEAD").getReverseEntries().size()); }
201202203204205206207208209210211
public void testDeleteHEADreferencedRef() throws IOException { ObjectId pid = db.resolve("refs/heads/master^"); RefUpdate updateRef = db.updateRef("refs/heads/master"); updateRef.setNewObjectId(pid); updateRef.setForceUpdate(true); Result update = updateRef.update(); assertEquals(Result.FORCED, update); // internal RefUpdate updateRef2 = db.updateRef("refs/heads/master"); Result delete = updateRef2.delete(); assertEquals(Result.REJECTED_CURRENT_BRANCH, delete);
216217218219220221222223224225226
@Test public void testLooseDelete() throws IOException { final String newRef = "refs/heads/abc"; RefUpdate ref = updateRef(newRef); ref.update(); // create loose ref ref = updateRef(newRef); // refresh delete(ref, Result.NO_CHANGE); assertNull(db.getReflogReader("refs/heads/abc")); }
243244245246247248249250251252253
ObjectId pid = db.resolve("refs/heads/c^"); RefUpdate updateRef = db.updateRef("refs/heads/z/c"); updateRef.setNewObjectId(pid); updateRef.setForceUpdate(true); updateRef.setRefLogMessage("new test ref", false); Result update = updateRef.update(); assertEquals(Result.NEW, update); // internal assertTrue(new File(db.getDirectory(), Constants.R_HEADS + "z") .exists()); assertTrue(new File(db.getDirectory(), "logs/refs/heads/z").exists());
287288289290291292293294295296297
public void testDeleteWithoutHead() throws IOException { // Prepare repository without HEAD RefUpdate refUpdate = db.updateRef(Constants.HEAD, true); refUpdate.setForceUpdate(true); refUpdate.setNewObjectId(ObjectId.zeroId()); Result updateResult = refUpdate.update(); assertEquals(Result.FORCED, updateResult); Result deleteHeadResult = db.updateRef(Constants.HEAD).delete(); assertEquals(Result.NO_CHANGE, deleteHeadResult); // Any result is ok as long as it's not an NPE
318319320321322323324325326327328
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");
325326327328329330331332333334335
assertEquals(ppid, db.resolve("refs/heads/master")); // real test RefUpdate updateRef2 = db.updateRef("refs/heads/master"); updateRef2.setNewObjectId(pid); Result update2 = updateRef2.update(); assertEquals(Result.FAST_FORWARD, update2); assertEquals(pid, db.resolve("refs/heads/master")); } /**
342343344345346347348349350351352
ObjectId pid = db.resolve("refs/heads/master"); ObjectId ppid = db.resolve("refs/heads/master^"); RefUpdate updateRef = db.updateRef("HEAD", true); updateRef.setForceUpdate(true); updateRef.setNewObjectId(ppid); Result update = updateRef.update(); assertEquals(Result.FORCED, update); assertEquals(ppid, db.resolve("HEAD")); Ref ref = db.getRef("HEAD"); assertEquals("HEAD", ref.getName()); assertTrue("is detached", !ref.isSymbolic());
372373374375376377378379380381382
ObjectId ppid = db.resolve("refs/heads/master^"); writeSymref("HEAD", "refs/heads/unborn"); RefUpdate updateRef = db.updateRef("HEAD", true); updateRef.setForceUpdate(true); updateRef.setNewObjectId(ppid); Result update = updateRef.update(); assertEquals(Result.NEW, update); assertEquals(ppid, db.resolve("HEAD")); Ref ref = db.getRef("HEAD"); assertEquals("HEAD", ref.getName()); assertTrue("is detached", !ref.isSymbolic());
402403404405406407408409410411412
public void testDeleteLoosePacked() throws IOException { ObjectId pid = db.resolve("refs/heads/c^"); RefUpdate updateRef = db.updateRef("refs/heads/c"); updateRef.setNewObjectId(pid); updateRef.setForceUpdate(true); Result update = updateRef.update(); assertEquals(Result.FORCED, update); // internal // The real test here RefUpdate updateRef2 = db.updateRef("refs/heads/c"); updateRef2.setForceUpdate(true);