Browse Source

ReceivePack: allow push options to be set

Some embeddings of JGit require creating a ReceivePack instance in
another process from the one that handled the network socket with the
client.  Similar to the PushCertificate add a setter to allow the
option list to be supplied.

Change-Id: I303a30e54942ad067c79251eff8b53329c406628
tags/v4.5.0.201609210915-r
Shawn Pearce 7 years ago
parent
commit
8e00a317b2
1 changed files with 18 additions and 6 deletions
  1. 18
    6
      org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java

+ 18
- 6
org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java View File

* @return an unmodifiable view of pushOptions, or null (if pushOptions is). * @return an unmodifiable view of pushOptions, or null (if pushOptions is).
* @throws IllegalStateException * @throws IllegalStateException
* if allowPushOptions has not been set to true. * if allowPushOptions has not been set to true.
* @throws RequestNotYetReadException
* if the client's request has not yet been read from the wire,
* so we do not know if they expect push options. Note that the
* client may have already written the request, it just has not
* been read.
* @since 4.5 * @since 4.5
*/ */
@Nullable @Nullable
// call doesn't make sense. // call doesn't make sense.
throw new IllegalStateException(); throw new IllegalStateException();
} }
checkRequestWasRead();
if (!usePushOptions) { if (!usePushOptions) {
// The client doesn't support push options. Return null to // The client doesn't support push options. Return null to
// distinguish this from the case where the client declared support // distinguish this from the case where the client declared support
return Collections.unmodifiableList(pushOptions); return Collections.unmodifiableList(pushOptions);
} }


/**
* Set the push options supplied by the client.
* <p>
* Should only be called if reconstructing an instance without going through
* the normal {@link #recvCommands()} flow.
*
* @param options
* the list of options supplied by the client. The
* {@code ReceivePack} instance takes ownership of this list.
* Callers are encouraged to first create a copy if the list may
* be modified later.
* @since 4.5
*/
public void setPushOptions(@Nullable List<String> options) {
usePushOptions = options != null;
pushOptions = options;
}

/** @return the hook invoked before updates occur. */ /** @return the hook invoked before updates occur. */
public PreReceiveHook getPreReceiveHook() { public PreReceiveHook getPreReceiveHook() {
return preReceive; return preReceive;

Loading…
Cancel
Save