public abstract class RefAdvertiser
extends java.lang.Object
UploadPack
and
ReceivePack
.Modifier and Type | Class and Description |
---|---|
static class |
RefAdvertiser.PacketLineOutRefAdvertiser
Advertiser which frames lines in a
PacketLineOut format. |
Modifier and Type | Field and Description |
---|---|
(package private) java.util.Set<java.lang.String> |
capablities |
private boolean |
derefTags |
(package private) boolean |
first |
private Repository |
repository |
private java.util.Set<ObjectId> |
sent |
private java.util.Map<java.lang.String,java.lang.String> |
symrefs |
private char[] |
tmpId |
private java.lang.StringBuilder |
tmpLine |
private boolean |
useProtocolV2 |
Constructor and Description |
---|
RefAdvertiser() |
Modifier and Type | Method and Description |
---|---|
void |
addSymref(java.lang.String from,
java.lang.String to)
Add a symbolic ref to capabilities.
|
private void |
advertiseAny(AnyObjectId obj,
java.lang.String refName) |
private void |
advertiseAnyOnce(AnyObjectId obj,
java.lang.String refName) |
void |
advertiseCapability(java.lang.String name)
Add one protocol capability to the initial advertisement.
|
void |
advertiseCapability(java.lang.String name,
java.lang.String value)
Add one protocol capability with a value (
"name=value" ). |
void |
advertiseHave(AnyObjectId id)
Advertise one object is available using the magic
.have . |
void |
advertiseId(AnyObjectId id,
java.lang.String refName)
Advertise one object under a specific name.
|
protected abstract void |
end()
Mark the end of the advertisements.
|
void |
init(Repository src)
Initialize this advertiser with a repository for peeling tags.
|
boolean |
isEmpty()
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.
use
send(Collection) instead. |
void |
setDerefTags(boolean deref)
Toggle tag peeling.
|
void |
setUseProtocolV2(boolean b) |
protected abstract void |
writeOne(java.lang.CharSequence line)
Write a single advertisement line.
|
private final java.lang.StringBuilder tmpLine
private final char[] tmpId
final java.util.Set<java.lang.String> capablities
private final java.util.Set<ObjectId> sent
private Repository repository
private boolean derefTags
boolean first
private boolean useProtocolV2
private final java.util.Map<java.lang.String,java.lang.String> symrefs
public void init(Repository src)
src
- the repository to read from.public void setUseProtocolV2(boolean b)
b
- true if this advertiser should advertise using the protocol
v2 format, false otherwisepublic void setDerefTags(boolean deref)
This method must be invoked prior to any of the following:
deref
- true to show the dereferenced value of a tag as the special
ref $tag^{}
; false to omit it from the output.public void advertiseCapability(java.lang.String name)
This method must be invoked prior to any of the following:
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.public void advertiseCapability(java.lang.String name, java.lang.String value)
"name=value"
).name
- name of the capability.value
- value. If null the capability will not be added.public void addSymref(java.lang.String from, java.lang.String to)
This method must be invoked prior to any of the following:
from
- The symbolic ref, e.g. "HEAD"to
- The real ref it points to, e.g. "refs/heads/master"@Deprecated public java.util.Set<ObjectId> send(java.util.Map<java.lang.String,Ref> refs) throws java.io.IOException
send(Collection)
instead.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.java.io.IOException
- the underlying output stream failed to write out an
advertisement record.public java.util.Set<ObjectId> send(java.util.Collection<Ref> refs) throws java.io.IOException
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.java.io.IOException
- the underlying output stream failed to write out an
advertisement record.public void advertiseHave(AnyObjectId id) throws java.io.IOException
.have
.
The magic .have
advertisement 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
.
id
- identity of the object that is assumed to exist.java.io.IOException
- the underlying output stream failed to write out an
advertisement record.public boolean isEmpty()
private void advertiseAnyOnce(AnyObjectId obj, java.lang.String refName) throws java.io.IOException
java.io.IOException
private void advertiseAny(AnyObjectId obj, java.lang.String refName) throws java.io.IOException
java.io.IOException
public void advertiseId(AnyObjectId id, java.lang.String refName) throws java.io.IOException
If the advertised object is a tag, this method does not advertise the peeled version of it.
id
- the object to advertise.refName
- name of the reference to advertise the object as, can be any
string not including the NUL byte.java.io.IOException
- the underlying output stream failed to write out an
advertisement record.protected abstract void writeOne(java.lang.CharSequence line) throws java.io.IOException
line
- the advertisement line to be written. The line always ends
with LF. Never null or the empty string.java.io.IOException
- the underlying output stream failed to write out an
advertisement record.protected abstract void end() throws java.io.IOException
java.io.IOException
- the underlying output stream failed to write out an
advertisement record.