Merge "UploadPack: Use reachable-sha1-in-want configuration"
This commit is contained in:
commit
719069680d
|
@ -193,6 +193,13 @@ public abstract class BasePackFetchConnection extends BasePackConnection
|
||||||
*/
|
*/
|
||||||
public static final String OPTION_ALLOW_TIP_SHA1_IN_WANT = GitProtocolConstants.OPTION_ALLOW_TIP_SHA1_IN_WANT;
|
public static final String OPTION_ALLOW_TIP_SHA1_IN_WANT = GitProtocolConstants.OPTION_ALLOW_TIP_SHA1_IN_WANT;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The client supports fetching objects that are reachable from a tip of a
|
||||||
|
* ref that is allowed to fetch.
|
||||||
|
* @since 4.1
|
||||||
|
*/
|
||||||
|
public static final String OPTION_ALLOW_REACHABLE_SHA1_IN_WANT = GitProtocolConstants.OPTION_ALLOW_REACHABLE_SHA1_IN_WANT;
|
||||||
|
|
||||||
private final RevWalk walk;
|
private final RevWalk walk;
|
||||||
|
|
||||||
/** All commits that are immediately reachable by a local ref. */
|
/** All commits that are immediately reachable by a local ref. */
|
||||||
|
|
|
@ -129,6 +129,14 @@ public class GitProtocolConstants {
|
||||||
*/
|
*/
|
||||||
public static final String OPTION_ALLOW_TIP_SHA1_IN_WANT = "allow-tip-sha1-in-want"; //$NON-NLS-1$
|
public static final String OPTION_ALLOW_TIP_SHA1_IN_WANT = "allow-tip-sha1-in-want"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The client supports fetching objects that are reachable from a tip of a
|
||||||
|
* ref that is allowed to fetch.
|
||||||
|
*
|
||||||
|
* @since 4.1
|
||||||
|
*/
|
||||||
|
public static final String OPTION_ALLOW_REACHABLE_SHA1_IN_WANT = "allow-reachable-sha1-in-want"; //$NON-NLS-1$
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Symbolic reference support for better negotiation.
|
* Symbolic reference support for better negotiation.
|
||||||
*
|
*
|
||||||
|
|
|
@ -71,6 +71,7 @@ public TransferConfig parse(final Config cfg) {
|
||||||
private final boolean safeForWindows;
|
private final boolean safeForWindows;
|
||||||
private final boolean safeForMacOS;
|
private final boolean safeForMacOS;
|
||||||
private final boolean allowTipSha1InWant;
|
private final boolean allowTipSha1InWant;
|
||||||
|
private final boolean allowReachableSha1InWant;
|
||||||
private final String[] hideRefs;
|
private final String[] hideRefs;
|
||||||
|
|
||||||
TransferConfig(final Repository db) {
|
TransferConfig(final Repository db) {
|
||||||
|
@ -94,6 +95,8 @@ private TransferConfig(final Config rc) {
|
||||||
|
|
||||||
allowTipSha1InWant = rc.getBoolean(
|
allowTipSha1InWant = rc.getBoolean(
|
||||||
"uploadpack", "allowtipsha1inwant", false); //$NON-NLS-1$ //$NON-NLS-2$
|
"uploadpack", "allowtipsha1inwant", false); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
allowReachableSha1InWant = rc.getBoolean(
|
||||||
|
"uploadpack", "allowreachablesha1inwant", false); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
hideRefs = rc.getStringList("uploadpack", null, "hiderefs"); //$NON-NLS-1$ //$NON-NLS-2$
|
hideRefs = rc.getStringList("uploadpack", null, "hiderefs"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,6 +123,14 @@ public boolean isAllowTipSha1InWant() {
|
||||||
return allowTipSha1InWant;
|
return allowTipSha1InWant;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return allow clients to request non-tip SHA-1s?
|
||||||
|
* @since 4.1
|
||||||
|
*/
|
||||||
|
public boolean isAllowReachableSha1InWant() {
|
||||||
|
return allowReachableSha1InWant;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {@link RefFilter} respecting configured hidden refs.
|
* @return {@link RefFilter} respecting configured hidden refs.
|
||||||
* @since 3.1
|
* @since 3.1
|
||||||
|
|
|
@ -46,6 +46,7 @@
|
||||||
import static org.eclipse.jgit.lib.RefDatabase.ALL;
|
import static org.eclipse.jgit.lib.RefDatabase.ALL;
|
||||||
import static org.eclipse.jgit.transport.GitProtocolConstants.OPTION_AGENT;
|
import static org.eclipse.jgit.transport.GitProtocolConstants.OPTION_AGENT;
|
||||||
import static org.eclipse.jgit.transport.GitProtocolConstants.OPTION_ALLOW_TIP_SHA1_IN_WANT;
|
import static org.eclipse.jgit.transport.GitProtocolConstants.OPTION_ALLOW_TIP_SHA1_IN_WANT;
|
||||||
|
import static org.eclipse.jgit.transport.GitProtocolConstants.OPTION_ALLOW_REACHABLE_SHA1_IN_WANT;
|
||||||
import static org.eclipse.jgit.transport.GitProtocolConstants.OPTION_INCLUDE_TAG;
|
import static org.eclipse.jgit.transport.GitProtocolConstants.OPTION_INCLUDE_TAG;
|
||||||
import static org.eclipse.jgit.transport.GitProtocolConstants.OPTION_MULTI_ACK;
|
import static org.eclipse.jgit.transport.GitProtocolConstants.OPTION_MULTI_ACK;
|
||||||
import static org.eclipse.jgit.transport.GitProtocolConstants.OPTION_MULTI_ACK_DETAILED;
|
import static org.eclipse.jgit.transport.GitProtocolConstants.OPTION_MULTI_ACK_DETAILED;
|
||||||
|
@ -552,8 +553,13 @@ public void setPackConfig(PackConfig pc) {
|
||||||
*/
|
*/
|
||||||
public void setTransferConfig(TransferConfig tc) {
|
public void setTransferConfig(TransferConfig tc) {
|
||||||
this.transferConfig = tc != null ? tc : new TransferConfig(db);
|
this.transferConfig = tc != null ? tc : new TransferConfig(db);
|
||||||
setRequestPolicy(transferConfig.isAllowTipSha1InWant()
|
if (transferConfig.isAllowTipSha1InWant()) {
|
||||||
? RequestPolicy.TIP : RequestPolicy.ADVERTISED);
|
setRequestPolicy(transferConfig.isAllowReachableSha1InWant()
|
||||||
|
? RequestPolicy.REACHABLE_COMMIT_TIP : RequestPolicy.TIP);
|
||||||
|
} else {
|
||||||
|
setRequestPolicy(transferConfig.isAllowReachableSha1InWant()
|
||||||
|
? RequestPolicy.REACHABLE_COMMIT : RequestPolicy.ADVERTISED);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return the configured logger. */
|
/** @return the configured logger. */
|
||||||
|
@ -808,6 +814,10 @@ public void sendAdvertisedRefs(final RefAdvertiser adv) throws IOException,
|
||||||
|| policy == RequestPolicy.REACHABLE_COMMIT_TIP
|
|| policy == RequestPolicy.REACHABLE_COMMIT_TIP
|
||||||
|| policy == null)
|
|| policy == null)
|
||||||
adv.advertiseCapability(OPTION_ALLOW_TIP_SHA1_IN_WANT);
|
adv.advertiseCapability(OPTION_ALLOW_TIP_SHA1_IN_WANT);
|
||||||
|
if (policy == RequestPolicy.REACHABLE_COMMIT
|
||||||
|
|| policy == RequestPolicy.REACHABLE_COMMIT_TIP
|
||||||
|
|| policy == null)
|
||||||
|
adv.advertiseCapability(OPTION_ALLOW_REACHABLE_SHA1_IN_WANT);
|
||||||
adv.advertiseCapability(OPTION_AGENT, UserAgent.get());
|
adv.advertiseCapability(OPTION_AGENT, UserAgent.get());
|
||||||
adv.setDerefTags(true);
|
adv.setDerefTags(true);
|
||||||
Map<String, Ref> advertisedOrDefaultRefs = getAdvertisedOrDefaultRefs();
|
Map<String, Ref> advertisedOrDefaultRefs = getAdvertisedOrDefaultRefs();
|
||||||
|
|
Loading…
Reference in New Issue