java.lang.Object
org.eclipse.jgit.transport.RefAdvertiser
- Direct Known Subclasses:
RefAdvertiser.PacketLineOutRefAdvertiser
Support for the start of
UploadPack
and
ReceivePack
.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Advertiser which frames lines in aPacketLineOut
format. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a symbolic ref to capabilities.void
advertiseCapability
(String name) Add one protocol capability to the initial advertisement.void
advertiseCapability
(String name, String value) Add one protocol capability with a value ("name=value"
).void
Advertise one object is available using the magic.have
.void
advertiseId
(AnyObjectId id, 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.send
(Collection<Ref> refs) Format an advertisement for the supplied refs.Deprecated.void
setDerefTags
(boolean deref) Toggle tag peeling.void
setUseProtocolV2
(boolean b) Set whether this advertiser should use protocol v2protected abstract void
writeOne
(CharSequence line) Write a single advertisement line.
-
Constructor Details
-
RefAdvertiser
public RefAdvertiser()
-
-
Method Details
-
init
Initialize this advertiser with a repository for peeling tags.- Parameters:
src
- the repository to read from.
-
setUseProtocolV2
public void setUseProtocolV2(boolean b) Set whether this advertiser should use protocol v2- 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
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
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
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.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:
IOException
- the underlying output stream failed to write out an advertisement record.
-
send
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:
IOException
- the underlying output stream failed to write out an advertisement record.- Since:
- 5.0
-
advertiseHave
Advertise one object is available using the magic.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
.- Parameters:
id
- identity of the object that is assumed to exist.- Throws:
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.
-
advertiseId
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:
IOException
- the underlying output stream failed to write out an advertisement record.
-
writeOne
Write 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:
IOException
- the underlying output stream failed to write out an advertisement record.
-
end
Mark the end of the advertisements.- Throws:
IOException
- the underlying output stream failed to write out an advertisement record.
-
send(Collection)
instead.