Source:
private void initAllProjects ( org.eclipse.jgit.lib.Repository git ) throws java.io.IOException , org.eclipse.jgit.errors.ConfigInvalidException { org.eclipse.jgit.lib.BatchRefUpdate bru = git.getRefDatabase ( ) . newBatchUpdate ( ) ; try ( com.google.gerrit.server.git.MetaDataUpdate md = new com.google.gerrit.server.git.MetaDataUpdate ( com.google.gerrit.server.extensions.events.GitReferenceUpdated.DISABLED , allProjectsName , git , bru ) ) { md.getCommitBuilder ( ) . setAuthor ( serverUser ) ; md.getCommitBuilder ( ) . setCommitter ( serverUser ) ; md.setMessage ( com.google.common.base.MoreObjects.firstNonNull ( com.google.common.base.Strings.emptyToNull ( message ) , ( "Initialized Gerrit Code Review " + ( com.google.gerrit.common.Version.getVersion ( ) ) ) ) ) ; com.google.gerrit.server.git.ProjectConfig config = com.google.gerrit.server.git.ProjectConfig.read ( md ) ; com.google.gerrit.reviewdb.client.Project p = config.getProject ( ) ; p.setDescription ( "Access inherited by all other projects." ) ; p.setRequireChangeID ( InheritableBoolean.TRUE ) ; p.setUseContentMerge ( InheritableBoolean.TRUE ) ; p.setUseContributorAgreements ( InheritableBoolean.FALSE ) ; p.setUseSignedOffBy ( InheritableBoolean.FALSE ) ; p.setEnableSignedPush ( InheritableBoolean.FALSE ) ; com.google.gerrit.common.data.AccessSection cap = config.getAccessSection ( AccessSection.GLOBAL_CAPABILITIES , true ) ; com.google.gerrit.common.data.AccessSection all = config.getAccessSection ( AccessSection.ALL , true ) ; com.google.gerrit.common.data.AccessSection heads = config.getAccessSection ( AccessSection.HEADS , true ) ; com.google.gerrit.common.data.AccessSection tags = config.getAccessSection ( "refs/tags/*" , true ) ; com.google.gerrit.common.data.AccessSection meta = config.getAccessSection ( RefNames.REFS_CONFIG , true ) ; com.google.gerrit.common.data.AccessSection refsFor = config.getAccessSection ( "refs/for/*" , true ) ; com.google.gerrit.common.data.AccessSection magic = config.getAccessSection ( ( "refs/for/" + ( com.google.gerrit.common.data.AccessSection.ALL ) ) , true ) ; com.google.gerrit.server.schema.AclUtil.grant ( config , cap , GlobalCapability.ADMINISTRATE_SERVER , admin ) ; com.google.gerrit.server.schema.AclUtil.grant ( config , all , Permission.READ , admin , anonymous ) ; com.google.gerrit.server.schema.AclUtil.grant ( config , refsFor , Permission.ADD_PATCH_SET , registered ) ; if ( ( batch ) != null ) { com.google.gerrit.common.data.Permission priority = cap.getPermission ( GlobalCapability.PRIORITY , true ) ; com.google.gerrit.common.data.PermissionRule r = com.google.gerrit.server.schema.AclUtil.rule ( config , batch ) ; r.setAction ( Action.BATCH ) ; priority.add ( r ) ; com.google.gerrit.common.data.Permission stream = cap.getPermission ( GlobalCapability.STREAM_EVENTS , true ) ; stream.add ( com.google.gerrit.server.schema.AclUtil.rule ( config , batch ) ) ; } com.google.gerrit.common.data.LabelType cr = com.google.gerrit.server.schema.AllProjectsCreator.initCodeReviewLabel ( config ) ; com.google.gerrit.server.schema.AclUtil.grant ( config , heads , cr , ( - 1 ) , 1 , registered ) ; com.google.gerrit.server.schema.AclUtil.grant ( config , heads , cr , ( - 2 ) , 2 , admin , owners ) ; com.google.gerrit.server.schema.AclUtil.grant ( config , heads , Permission.CREATE , admin , owners ) ; com.google.gerrit.server.schema.AclUtil.grant ( config , heads , Permission.PUSH , admin , owners ) ; com.google.gerrit.server.schema.AclUtil.grant ( config , heads , Permission.SUBMIT , admin , owners ) ; com.google.gerrit.server.schema.AclUtil.grant ( config , heads , Permission.FORGE_AUTHOR , registered ) ; com.google.gerrit.server.schema.AclUtil.grant ( config , heads , Permission.FORGE_COMMITTER , admin , owners ) ; com.google.gerrit.server.schema.AclUtil.grant ( config , heads , Permission.EDIT_TOPIC_NAME , true , admin , owners ) ; com.google.gerrit.server.schema.AclUtil.grant ( config , tags , Permission.CREATE , admin , owners ) ; com.google.gerrit.server.schema.AclUtil.grant ( config , tags , Permission.CREATE_TAG , admin , owners ) ; com.google.gerrit.server.schema.AclUtil.grant ( config , tags , Permission.CREATE_SIGNED_TAG , admin , owners ) ; com.google.gerrit.server.schema.AclUtil.grant ( config , magic , Permission.PUSH , registered ) ; com.google.gerrit.server.schema.AclUtil.grant ( config , magic , Permission.PUSH_MERGE , registered ) ; meta.getPermission ( Permission.READ , true ) . setExclusiveGroup ( true ) ; com.google.gerrit.server.schema.AclUtil.grant ( config , meta , Permission.READ , admin , owners ) ; com.google.gerrit.server.schema.AclUtil.grant ( config , meta , cr , ( - 2 ) , 2 , admin , owners ) ; com.google.gerrit.server.schema.AclUtil.grant ( config , meta , Permission.CREATE , admin , owners ) ; com.google.gerrit.server.schema.AclUtil.grant ( config , meta , Permission.PUSH , admin , owners ) ; com.google.gerrit.server.schema.AclUtil.grant ( config , meta , Permission.SUBMIT , admin , owners ) ; config.commitToNewRef ( md , RefNames.REFS_CONFIG ) ; if ( ( notesMigration.readChangeSequence ( ) ) && ( ( git.exactRef ( ( ( com.google.gerrit.reviewdb.client.RefNames.REFS_SEQUENCES ) + ( com.google.gerrit.server.Sequences.CHANGES ) ) ) ) == null ) ) { try ( org.eclipse.jgit.lib.ObjectInserter ins = git.newObjectInserter ( ) ) { bru.addCommand ( com.google.gerrit.server.notedb.RepoSequence.storeNew ( ins , Sequences.CHANGES , ReviewDb.FIRST_CHANGE_ID ) ) ; ins.flush ( ) ; } } try ( org.eclipse.jgit.revwalk.RevWalk rw = new org.eclipse.jgit.revwalk.RevWalk ( git ) ) { bru.execute ( rw , NullProgressMonitor.INSTANCE ) ; } for ( org.eclipse.jgit.transport.ReceiveCommand cmd : bru.getCommands ( ) ) { if ( ( cmd.getResult ( ) ) != ( ReceiveCommand.Result.OK ) ) { throw new java.io.IOException ( ( "Failed to initialize All-Users refs:\n" + bru ) ) ; } } } }

Target:
private void initSequences ( org.eclipse.jgit.lib.Repository git , org.eclipse.jgit.lib.BatchRefUpdate bru ) throws java.io.IOException { if ( ( notesMigration.readChangeSequence ( ) ) && ( ( git.exactRef ( ( ( com.google.gerrit.reviewdb.client.RefNames.REFS_SEQUENCES ) + ( com.google.gerrit.server.Sequences.CHANGES ) ) ) ) == null ) ) { try ( org.eclipse.jgit.lib.ObjectInserter ins = git.newObjectInserter ( ) ) { bru.addCommand ( com.google.gerrit.server.notedb.RepoSequence.storeNew ( ins , Sequences.CHANGES , firstChangeId ) ) ; ins.flush ( ) ; } } }