Example usage for org.eclipse.jgit.transport ReceivePack setAllowNonFastForwards

List of usage examples for org.eclipse.jgit.transport ReceivePack setAllowNonFastForwards

Introduction

In this page you can find the example usage for org.eclipse.jgit.transport ReceivePack setAllowNonFastForwards.

Prototype

public void setAllowNonFastForwards(boolean canRewind) 

Source Link

Document

Configure whether to permit the client to ask for non-fast-forward updates of an existing ref.

Usage

From source file:com.sonatype.sshjgit.core.gitcommand.Receive.java

License:Apache License

@Override
protected void runImpl() throws IOException, Failure {
    final Subject subject = SecurityUtils.getSubject();
    subject.checkPermission("gitrepo:push:" + getRepoNameAsPermissionParts(repo));
    ReceivePack rp = new ReceivePack(repo);
    rp.setAllowCreates(true);//from   w  w w. j  a va  2s  .  c  o m
    final boolean mayNonFastForward = subject
            .isPermitted("gitrepo:non-fast-forward:" + getRepoNameAsPermissionParts(repo));
    rp.setAllowDeletes(mayNonFastForward);
    rp.setAllowNonFastForwards(mayNonFastForward);
    rp.setCheckReceivedObjects(true);
    // TODO make this be a real email address!
    final String name;
    final Object principal = subject.getPrincipal();
    if (principal == null) {
        name = "null_principal";
        log.warn("principal was null when trying to setRefLogIdent on repo.");
    } else {
        name = principal.toString();
    }
    log.info("setting LogIdent to " + name);
    rp.setRefLogIdent(new PersonIdent(name, name + "@example.com"));
    rp.receive(in, out, err);
}