assertEquals(A.getId(), refs.get("refs/heads/masters").getObjectId());
}
+ @Test
+ public void testBatchRefUpdateNonFastForwardDoesNotDoExpensiveMergeCheck()
+ throws IOException {
+ writeLooseRef("refs/heads/master", B);
+ List<ReceiveCommand> commands = Arrays.asList(
+ newCommand(B, A, "refs/heads/master",
+ ReceiveCommand.Type.UPDATE_NONFASTFORWARD));
+ BatchRefUpdate batchUpdate = refdir.newBatchUpdate();
+ batchUpdate.setAllowNonFastForwards(true);
+ batchUpdate.addCommand(commands);
+ batchUpdate.execute(new RevWalk(diskRepo) {
+ @Override
+ public boolean isMergedInto(RevCommit base, RevCommit tip) {
+ throw new AssertionError("isMergedInto() should not be called");
+ }
+ }, new StrictWorkMonitor());
+ Map<String, Ref> refs = refdir.getRefs(RefDatabase.ALL);
+ assertEquals(ReceiveCommand.Result.OK, commands.get(0).getResult());
+ assertEquals(A.getId(), refs.get("refs/heads/master").getObjectId());
+ }
+
@Test
public void testBatchRefUpdateConflict() throws IOException {
writeLooseRef("refs/heads/master", A);
if (newObj == oldObj && !detachingSymbolicRef)
return store.execute(Result.NO_CHANGE);
+ if (isForceUpdate())
+ return store.execute(Result.FORCED);
+
if (newObj instanceof RevCommit && oldObj instanceof RevCommit) {
if (walk.isMergedInto((RevCommit) oldObj, (RevCommit) newObj))
return store.execute(Result.FAST_FORWARD);
}
- if (isForceUpdate())
- return store.execute(Result.FORCED);
return Result.REJECTED;
} finally {
unlock();