aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.jgit/.settings/.api_filters12
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/AdvertiseRefsHook.java4
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/AdvertiseRefsHookChain.java2
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java33
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java56
5 files changed, 80 insertions, 27 deletions
diff --git a/org.eclipse.jgit/.settings/.api_filters b/org.eclipse.jgit/.settings/.api_filters
index af529a027a..ac2d094327 100644
--- a/org.eclipse.jgit/.settings/.api_filters
+++ b/org.eclipse.jgit/.settings/.api_filters
@@ -34,6 +34,12 @@
<filter id="421650549">
<message_arguments>
<message_argument value="org.eclipse.jgit.transport.BaseReceivePack"/>
+ <message_argument value="getAdvertisedRefs()"/>
+ </message_arguments>
+ </filter>
+ <filter id="421650549">
+ <message_arguments>
+ <message_argument value="org.eclipse.jgit.transport.BaseReceivePack"/>
<message_argument value="getPushCertificate()"/>
</message_arguments>
</filter>
@@ -52,6 +58,12 @@
<filter id="421650549">
<message_arguments>
<message_argument value="org.eclipse.jgit.transport.BaseReceivePack"/>
+ <message_argument value="setAdvertisedRefs(Map&lt;String,Ref&gt;, Set&lt;ObjectId&gt;)"/>
+ </message_arguments>
+ </filter>
+ <filter id="421650549">
+ <message_arguments>
+ <message_argument value="org.eclipse.jgit.transport.BaseReceivePack"/>
<message_argument value="setPushCertificate(PushCertificate)"/>
</message_arguments>
</filter>
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/AdvertiseRefsHook.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/AdvertiseRefsHook.java
index 72b4255df9..8512f2d9fe 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/AdvertiseRefsHook.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/AdvertiseRefsHook.java
@@ -53,7 +53,7 @@ public interface AdvertiseRefsHook {
* <p>
* The method implementations do nothing to preserve the default behavior; see
* {@link UploadPack#setAdvertisedRefs(java.util.Map)} and
- * {@link BaseReceivePack#setAdvertisedRefs(java.util.Map,java.util.Set)}.
+ * {@link ReceivePack#setAdvertisedRefs(java.util.Map,java.util.Set)}.
*/
AdvertiseRefsHook DEFAULT = new AdvertiseRefsHook() {
@Override
@@ -85,7 +85,7 @@ public interface AdvertiseRefsHook {
*
* @param receivePack
* instance on which to call
- * {@link org.eclipse.jgit.transport.BaseReceivePack#setAdvertisedRefs(java.util.Map,java.util.Set)}
+ * {@link org.eclipse.jgit.transport.ReceivePack#setAdvertisedRefs(java.util.Map,java.util.Set)}
* if necessary.
* @throws org.eclipse.jgit.transport.ServiceMayNotContinueException
* abort; the message will be sent to the user.
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/AdvertiseRefsHookChain.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/AdvertiseRefsHookChain.java
index 4ef3e1a974..12238a1f77 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/AdvertiseRefsHookChain.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/AdvertiseRefsHookChain.java
@@ -52,7 +52,7 @@ import java.util.List;
* Hooks are run in the order passed to the constructor. A hook may inspect or
* modify the results of the previous hooks in the chain by calling
* {@link org.eclipse.jgit.transport.UploadPack#getAdvertisedRefs()}, or
- * {@link org.eclipse.jgit.transport.BaseReceivePack#getAdvertisedRefs()} or
+ * {@link org.eclipse.jgit.transport.ReceivePack#getAdvertisedRefs()} or
* {@link org.eclipse.jgit.transport.BaseReceivePack#getAdvertisedObjects()}.
*/
public class AdvertiseRefsHookChain implements AdvertiseRefsHook {
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 e7d15683be..ddf6dcc9d2 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java
@@ -204,7 +204,7 @@ public abstract class BaseReceivePack {
private AdvertiseRefsHook advertiseRefsHook;
/** Filter used while advertising the refs to the client. */
- private RefFilter refFilter;
+ RefFilter refFilter;
/** Timeout in seconds to wait for client interaction. */
private int timeout;
@@ -239,10 +239,10 @@ public abstract class BaseReceivePack {
private PackParser parser;
/** The refs we advertised as existing at the start of the connection. */
- private Map<String, Ref> refs;
+ Map<String, Ref> refs;
/** All SHA-1s shown to the client, which can be possible edges. */
- private Set<ObjectId> advertisedHaves;
+ Set<ObjectId> advertisedHaves;
/** Capabilities requested by the client. */
private Set<String> enabledCapabilities;
@@ -440,10 +440,10 @@ public abstract class BaseReceivePack {
*
* @return all refs which were advertised to the client, or null if
* {@link #setAdvertisedRefs(Map, Set)} has not been called yet.
+ * @deprecated use {@link ReceivePack#getAdvertisedRefs}
*/
- public final Map<String, Ref> getAdvertisedRefs() {
- return refs;
- }
+ @Deprecated
+ public abstract Map<String, Ref> getAdvertisedRefs();
/**
* Set the refs advertised by this ReceivePack.
@@ -461,25 +461,10 @@ public abstract class BaseReceivePack {
* explicit set of additional haves to claim as advertised. If
* null, assumes the default set of additional haves from the
* repository.
+ * @deprecated use {@link ReceivePack#setAdvertisedRefs}
*/
- public void setAdvertisedRefs(Map<String, Ref> allRefs, Set<ObjectId> additionalHaves) {
- refs = allRefs != null ? allRefs : db.getAllRefs();
- refs = refFilter.filter(refs);
- advertisedHaves.clear();
-
- Ref head = refs.get(Constants.HEAD);
- if (head != null && head.isSymbolic())
- refs.remove(Constants.HEAD);
-
- for (Ref ref : refs.values()) {
- if (ref.getObjectId() != null)
- advertisedHaves.add(ref.getObjectId());
- }
- if (additionalHaves != null)
- advertisedHaves.addAll(additionalHaves);
- else
- advertisedHaves.addAll(db.getAdditionalHaves());
- }
+ @Deprecated
+ public abstract void setAdvertisedRefs(Map<String, Ref> allRefs, Set<ObjectId> additionalHaves);
/**
* Get objects advertised to the client.
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 91bf39e28a..4652c3fda8 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java
@@ -43,6 +43,7 @@
package org.eclipse.jgit.transport;
+import static org.eclipse.jgit.lib.Constants.HEAD;
import static org.eclipse.jgit.transport.GitProtocolConstants.CAPABILITY_ATOMIC;
import static org.eclipse.jgit.transport.GitProtocolConstants.CAPABILITY_PUSH_OPTIONS;
import static org.eclipse.jgit.transport.GitProtocolConstants.CAPABILITY_REPORT_STATUS;
@@ -53,12 +54,16 @@ import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import java.util.Map;
+import java.util.Set;
import org.eclipse.jgit.annotations.Nullable;
import org.eclipse.jgit.errors.UnpackException;
import org.eclipse.jgit.lib.ConfigConstants;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.NullProgressMonitor;
+import org.eclipse.jgit.lib.ObjectId;
+import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevWalk;
import org.eclipse.jgit.transport.ReceiveCommand.Result;
@@ -114,6 +119,57 @@ public class ReceivePack extends BaseReceivePack {
}
/**
+ * Get refs which were advertised to the client.
+ *
+ * @return all refs which were advertised to the client, or null if
+ * {@link #setAdvertisedRefs(Map, Set)} has not been called yet.
+ */
+ @Override
+ public final Map<String, Ref> getAdvertisedRefs() {
+ return refs;
+ }
+
+ /**
+ * Set the refs advertised by this ReceivePack.
+ * <p>
+ * Intended to be called from a
+ * {@link org.eclipse.jgit.transport.PreReceiveHook}.
+ *
+ * @param allRefs
+ * explicit set of references to claim as advertised by this
+ * ReceivePack instance. This overrides any references that may
+ * exist in the source repository. The map is passed to the
+ * configured {@link #getRefFilter()}. If null, assumes all refs
+ * were advertised.
+ * @param additionalHaves
+ * explicit set of additional haves to claim as advertised. If
+ * null, assumes the default set of additional haves from the
+ * repository.
+ */
+ @Override
+ public void setAdvertisedRefs(Map<String, Ref> allRefs, Set<ObjectId> additionalHaves) {
+ refs = allRefs != null ? allRefs : db.getAllRefs();
+ refs = refFilter.filter(refs);
+ advertisedHaves.clear();
+
+ Ref head = refs.get(HEAD);
+ if (head != null && head.isSymbolic()) {
+ refs.remove(HEAD);
+ }
+
+ for (Ref ref : refs.values()) {
+ if (ref.getObjectId() != null) {
+ advertisedHaves.add(ref.getObjectId());
+ }
+ }
+ if (additionalHaves != null) {
+ advertisedHaves.addAll(additionalHaves);
+ } else {
+ advertisedHaves.addAll(db.getAdditionalHaves());
+ }
+ }
+
+ /**
* Get the push certificate used to verify the pusher's identity.
* <p>
* Only valid after commands are read from the wire.