diff options
author | Shawn Pearce <spearce@spearce.org> | 2016-08-29 12:12:23 -0700 |
---|---|---|
committer | Shawn Pearce <spearce@spearce.org> | 2016-08-29 12:31:22 -0700 |
commit | 2fd4559773cecc803dc0c27a5cc801dc6575981f (patch) | |
tree | b3105c0ab0de5f4494d25e415914ee11c0801073 | |
parent | 8e00a317b25a4b34890a6327554c929310009b8b (diff) | |
download | jgit-2fd4559773cecc803dc0c27a5cc801dc6575981f.tar.gz jgit-2fd4559773cecc803dc0c27a5cc801dc6575981f.zip |
ReceivePack: simplify getPushOptions
Checking if the instance allows push options before returning the
collection or null is a bit overkill. Just return the collection
or return null.
Change-Id: Icdc3755194373966e5819284aeb9bfe8dd34de82
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java | 20 |
1 files changed, 7 insertions, 13 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 cea004b515..2e3d74a147 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java @@ -96,24 +96,18 @@ public class ReceivePack extends BaseReceivePack { * Gets an unmodifiable view of the option strings associated with the push. * * @return an unmodifiable view of pushOptions, or null (if pushOptions is). - * @throws IllegalStateException - * if allowPushOptions has not been set to true. * @since 4.5 */ @Nullable public List<String> getPushOptions() { - if (!isAllowPushOptions()) { - // Reading push options without a prior setAllowPushOptions(true) - // call doesn't make sense. - throw new IllegalStateException(); + if (isAllowPushOptions() && usePushOptions) { + return Collections.unmodifiableList(pushOptions); } - if (!usePushOptions) { - // The client doesn't support push options. Return null to - // distinguish this from the case where the client declared support - // for push options and sent an empty list of them. - return null; - } - return Collections.unmodifiableList(pushOptions); + + // The client doesn't support push options. Return null to + // distinguish this from the case where the client declared support + // for push options and sent an empty list of them. + return null; } /** |