summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Beller <sbeller@google.com>2016-08-26 14:10:06 -0700
committerShawn Pearce <spearce@spearce.org>2016-08-26 14:52:07 -0700
commit36cf4fe580a2b771331e0b9bcaea5505b3b7e27a (patch)
treef4ad0966839105859fb8057b91efe3197c20ca77
parent3b64c09ac48ef30b0ce5867a01cbbd62a5434df9 (diff)
downloadjgit-36cf4fe580a2b771331e0b9bcaea5505b3b7e27a.tar.gz
jgit-36cf4fe580a2b771331e0b9bcaea5505b3b7e27a.zip
Fix push option initalization on HTTP
Initialize pushOptions when we decide to use them, instead of when we advertise them. In the case of HTTP the advertisement is in a different network request, hence in a different instance of the BaseReceivePack. Change-Id: I094c60942e04de82cb6d8433c9cd43a46ffae332 Signed-off-by: Stefan Beller <sbeller@google.com>
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushOptionsTest.java2
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java4
2 files changed, 4 insertions, 2 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushOptionsTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushOptionsTest.java
index 1554f84305..8ff0226183 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushOptionsTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushOptionsTest.java
@@ -220,7 +220,7 @@ public class PushOptionsTest extends RepositoryTestCase {
one.getStatus());
assertSame(RemoteRefUpdate.Status.REJECTED_REMOTE_CHANGED,
two.getStatus());
- assertEquals(new ArrayList<String>(), baseReceivePack.getPushOptions());
+ assertNull(baseReceivePack.getPushOptions());
}
@Test
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java
index 4bd3af2f87..825e294d98 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java
@@ -1152,7 +1152,6 @@ public abstract class BaseReceivePack {
adv.advertiseCapability(CAPABILITY_OFS_DELTA);
if (allowPushOptions) {
adv.advertiseCapability(CAPABILITY_PUSH_OPTIONS);
- pushOptions = new ArrayList<>();
}
adv.advertiseCapability(OPTION_AGENT, UserAgent.get());
adv.send(getAdvertisedOrDefaultRefs());
@@ -1272,6 +1271,9 @@ public abstract class BaseReceivePack {
quiet = allowQuiet && isCapabilityEnabled(CAPABILITY_QUIET);
usePushOptions = allowPushOptions
&& isCapabilityEnabled(CAPABILITY_PUSH_OPTIONS);
+ if (usePushOptions) {
+ pushOptions = new ArrayList<>();
+ }
if (sideBand) {
OutputStream out = rawOut;