Package org.eclipse.jgit.transport
Class RefAdvertiser
- java.lang.Object
-
- org.eclipse.jgit.transport.RefAdvertiser
-
- Direct Known Subclasses:
RefAdvertiser.PacketLineOutRefAdvertiser
public abstract class RefAdvertiser extends java.lang.ObjectSupport for the start ofUploadPackandReceivePack.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classRefAdvertiser.PacketLineOutRefAdvertiserAdvertiser which frames lines in aPacketLineOutformat.
-
Field Summary
Fields Modifier and Type Field Description (package private) java.util.Set<java.lang.String>capablitiesprivate booleanderefTags(package private) booleanfirstprivate Repositoryrepositoryprivate java.util.Set<ObjectId>sentprivate java.util.Map<java.lang.String,java.lang.String>symrefsprivate char[]tmpIdprivate java.lang.StringBuildertmpLineprivate booleanuseProtocolV2
-
Constructor Summary
Constructors Constructor Description RefAdvertiser()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddSymref(java.lang.String from, java.lang.String to)Add a symbolic ref to capabilities.private voidadvertiseAny(AnyObjectId obj, java.lang.String refName)private voidadvertiseAnyOnce(AnyObjectId obj, java.lang.String refName)voidadvertiseCapability(java.lang.String name)Add one protocol capability to the initial advertisement.voidadvertiseCapability(java.lang.String name, java.lang.String value)Add one protocol capability with a value ("name=value").voidadvertiseHave(AnyObjectId id)Advertise one object is available using the magic.have.voidadvertiseId(AnyObjectId id, java.lang.String refName)Advertise one object under a specific name.protected abstract voidend()Mark the end of the advertisements.voidinit(Repository src)Initialize this advertiser with a repository for peeling tags.booleanisEmpty()Whether no advertisements have been sent yet.java.util.Set<ObjectId>send(java.util.Collection<Ref> refs)Format an advertisement for the supplied refs.java.util.Set<ObjectId>send(java.util.Map<java.lang.String,Ref> refs)Deprecated.usesend(Collection)instead.voidsetDerefTags(boolean deref)Toggle tag peeling.voidsetUseProtocolV2(boolean b)protected abstract voidwriteOne(java.lang.CharSequence line)Write a single advertisement line.
-
-
-
Field Detail
-
tmpLine
private final java.lang.StringBuilder tmpLine
-
tmpId
private final char[] tmpId
-
capablities
final java.util.Set<java.lang.String> capablities
-
sent
private final java.util.Set<ObjectId> sent
-
repository
private Repository repository
-
derefTags
private boolean derefTags
-
first
boolean first
-
useProtocolV2
private boolean useProtocolV2
-
symrefs
private final java.util.Map<java.lang.String,java.lang.String> symrefs
-
-
Method Detail
-
init
public void init(Repository src)
Initialize this advertiser with a repository for peeling tags.- Parameters:
src- the repository to read from.
-
setUseProtocolV2
public void setUseProtocolV2(boolean b)
- Parameters:
b- true if this advertiser should advertise using the protocol v2 format, false otherwise- Since:
- 5.0
-
setDerefTags
public void setDerefTags(boolean deref)
Toggle tag peeling.This method must be invoked prior to any of the following:
- Parameters:
deref- true to show the dereferenced value of a tag as the special ref$tag^{}; false to omit it from the output.
-
advertiseCapability
public void advertiseCapability(java.lang.String name)
Add one protocol capability to the initial advertisement.This method must be invoked prior to any of the following:
- Parameters:
name- the name of a single protocol capability supported by the caller. The set of capabilities are sent to the client in the advertisement, allowing the client to later selectively enable features it recognizes.
-
advertiseCapability
public void advertiseCapability(java.lang.String name, java.lang.String value)Add one protocol capability with a value ("name=value").- Parameters:
name- name of the capability.value- value. If null the capability will not be added.- Since:
- 4.0
-
addSymref
public void addSymref(java.lang.String from, java.lang.String to)Add a symbolic ref to capabilities.This method must be invoked prior to any of the following:
- Parameters:
from- The symbolic ref, e.g. "HEAD"to- The real ref it points to, e.g. "refs/heads/master"- Since:
- 3.6
-
send
@Deprecated public java.util.Set<ObjectId> send(java.util.Map<java.lang.String,Ref> refs) throws java.io.IOException
Deprecated.usesend(Collection)instead.Format an advertisement for the supplied refs.- Parameters:
refs- zero or more refs to format for the client. The collection is sorted before display if necessary, and therefore may appear in any order.- Returns:
- set of ObjectIds that were advertised to the client.
- Throws:
java.io.IOException- the underlying output stream failed to write out an advertisement record.
-
send
public java.util.Set<ObjectId> send(java.util.Collection<Ref> refs) throws java.io.IOException
Format an advertisement for the supplied refs.- Parameters:
refs- zero or more refs to format for the client. The collection is sorted before display if necessary, and therefore may appear in any order.- Returns:
- set of ObjectIds that were advertised to the client.
- Throws:
java.io.IOException- the underlying output stream failed to write out an advertisement record.- Since:
- 5.0
-
advertiseHave
public void advertiseHave(AnyObjectId id) throws java.io.IOException
Advertise one object is available using the magic.have.The magic
.haveadvertisement is not available for fetching by a client, but can be used by a client when considering a delta base candidate before transferring data in a push. Within the record created by this method the ref name is simply the invalid string.have.- Parameters:
id- identity of the object that is assumed to exist.- Throws:
java.io.IOException- the underlying output stream failed to write out an advertisement record.
-
isEmpty
public boolean isEmpty()
Whether no advertisements have been sent yet.- Returns:
- true if no advertisements have been sent yet.
-
advertiseAnyOnce
private void advertiseAnyOnce(AnyObjectId obj, java.lang.String refName) throws java.io.IOException
- Throws:
java.io.IOException
-
advertiseAny
private void advertiseAny(AnyObjectId obj, java.lang.String refName) throws java.io.IOException
- Throws:
java.io.IOException
-
advertiseId
public void advertiseId(AnyObjectId id, java.lang.String refName) throws java.io.IOException
Advertise one object under a specific name.If the advertised object is a tag, this method does not advertise the peeled version of it.
- Parameters:
id- the object to advertise.refName- name of the reference to advertise the object as, can be any string not including the NUL byte.- Throws:
java.io.IOException- the underlying output stream failed to write out an advertisement record.
-
writeOne
protected abstract void writeOne(java.lang.CharSequence line) throws java.io.IOExceptionWrite a single advertisement line.- Parameters:
line- the advertisement line to be written. The line always ends with LF. Never null or the empty string.- Throws:
java.io.IOException- the underlying output stream failed to write out an advertisement record.
-
end
protected abstract void end() throws java.io.IOExceptionMark the end of the advertisements.- Throws:
java.io.IOException- the underlying output stream failed to write out an advertisement record.
-
-