diff options
author | Shawn Pearce <spearce@spearce.org> | 2016-08-29 11:54:15 -0700 |
---|---|---|
committer | Shawn Pearce <spearce@spearce.org> | 2016-08-29 12:31:22 -0700 |
commit | 8e00a317b25a4b34890a6327554c929310009b8b (patch) | |
tree | 30e7283d8cf8f529b4b897b9db46d655cacf6cf7 | |
parent | dd2a5a7faf66da61957ccf6a5241eef82bc0d2a4 (diff) | |
download | jgit-8e00a317b25a4b34890a6327554c929310009b8b.tar.gz jgit-8e00a317b25a4b34890a6327554c929310009b8b.zip |
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
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java index 842c2d0626..cea004b515 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java @@ -98,11 +98,6 @@ public class ReceivePack extends BaseReceivePack { * @return an unmodifiable view of pushOptions, or null (if pushOptions is). * @throws IllegalStateException * 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 */ @Nullable @@ -112,7 +107,6 @@ public class ReceivePack extends BaseReceivePack { // call doesn't make sense. throw new IllegalStateException(); } - checkRequestWasRead(); if (!usePushOptions) { // The client doesn't support push options. Return null to // distinguish this from the case where the client declared support @@ -122,6 +116,24 @@ public class ReceivePack extends BaseReceivePack { 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. */ public PreReceiveHook getPreReceiveHook() { return preReceive; |