Top Description Fields Constructors Methods
org.eclipse.jgit.revwalk

public Class RevTag

extends RevObject
Class Inheritance
Static Imports
java.nio.charset.StandardCharsets.UTF_8

An annotated tag.

Field Summary

Modifier and TypeField and Description
private byte[]
private static final byte[]
private static final byte[]
private RevObject
private static final byte[]
private static final byte[]
private String
Inherited from org.eclipse.jgit.revwalk.RevObject:
flagsPARSED

Constructor Summary

AccessConstructor and Description
protected
RevTag(AnyObjectId
object name for the tag.
id
)

Create a new tag reference.

Method Summary

Modifier and TypeMethod and Description
public final void
disposeBody()

Discard the message buffer to reduce memory usage.

public final String

Returns:

decoded tag message as a string. Never null.
getFullMessage
()

Parse the complete tag message and decode it to a string.

public final RevObject

Returns:

object this tag refers to (only looked up, not parsed)
getObject
()

Get a reference to the object this tag was placed on.

public final byte[]

Returns:

the raw unparsed tag body. This is NOT A COPY. Do not alter the returned array.
getRawBuffer
()

Obtain the raw unparsed tag body (NOTE - THIS IS NOT A COPY).

public final byte[]

Returns:

contents of the GPG signature; null if the tag was not signed.
getRawGpgSignature
()

Parse the GPG signature from the raw buffer.

public final String

Returns:

decoded tag message as a string. Never null. The returned string does not contain any LFs, even if the first paragraph spanned multiple lines. Embedded LFs are converted to spaces.
getShortMessage
()

Parse the tag message and return the first "line" of it.

private int
public final PersonIdent

Returns:

identity of the tagger (name, email) and the time the tag was made by the tagger; null if no tagger line was found.
getTaggerIdent
()

Parse the tagger identity from the raw buffer.

public final String

Returns:

name of the tag, according to the tag header.
getTagName
()

Get the name of this tag, from the tag header.

public final int
getType()

Implements abstract org.eclipse.jgit.revwalk.RevObject.getType.

Get Git object type.

private Charset
private static int
nextStart(byte[] prefix, byte[] buffer, int from)

public static RevTag

Returns:

the parsed tag, in an isolated revision pool that is not available to the caller.
parse
(byte[]
the canonical formatted tag to be parsed.
raw
)

Parse an annotated tag from its canonical format.

public static RevTag

Returns:

the parsed tag, in an isolated revision pool that is not available to the caller.
parse
(RevWalk
the revision pool to allocate the tag within. The tag's object pointer will be obtained from this pool.
rw
,
byte[]
the canonical formatted tag to be parsed. This buffer will be retained by the returned RevTag and must not be modified by the caller.
raw
)

Parse an annotated tag from its canonical format.

pack-priv void
pack-priv void
parseCanonical(RevWalk walk, byte[] rawTag)

pack-priv void
Inherited from org.eclipse.jgit.revwalk.RevObject:
addaddappendCoreFlagsgetIdhashasAllhasAnyremoveremovetoString

Field Detail

bufferback to summary
private byte[] buffer
CMS_SIGNATURE_STARTback to summary
private static final byte[] CMS_SIGNATURE_START
GPG_SIGNATURE_STARTback to summary
private static final byte[] GPG_SIGNATURE_START
objectback to summary
private RevObject object
SIGNATURE_STARTback to summary
private static final byte[] SIGNATURE_START
SSH_SIGNATURE_STARTback to summary
private static final byte[] SSH_SIGNATURE_START
tagNameback to summary
private String tagName

Constructor Detail

RevTagback to summary
protected RevTag(AnyObjectId id)

Create a new tag reference.

Parameters
id:AnyObjectId

object name for the tag.

Method Detail

disposeBodyback to summary
public final void disposeBody()

Discard the message buffer to reduce memory usage.

After discarding the memory usage of the RevTag is reduced to only the getObject() pointer and getTagName(). Accessing other properties such as getTaggerIdent() or either message function requires reloading the buffer by invoking org.eclipse.jgit.revwalk.RevWalk#parseBody(RevObject).

Since
4.0
getFullMessageback to summary
public final String getFullMessage()

Parse the complete tag message and decode it to a string.

This method parses and returns the message portion of the tag buffer, after taking the tag's character set into account and decoding the buffer using that character set. This method is a fairly expensive operation and produces a new string on each invocation.

Returns:String

decoded tag message as a string. Never null.

getObjectback to summary
public final RevObject getObject()

Get a reference to the object this tag was placed on.

Note that the returned object has only been looked up (see org.eclipse.jgit.revwalk.RevWalk#lookupAny(AnyObjectId, int). To access the contents it needs to be parsed, see org.eclipse.jgit.revwalk.RevWalk#parseHeaders(RevObject) and org.eclipse.jgit.revwalk.RevWalk#parseBody(RevObject).

As an alternative, use org.eclipse.jgit.revwalk.RevWalk#peel(RevObject) and pass this org.eclipse.jgit.revwalk.RevTag to peel it until the first non-tag object.

Returns:RevObject

object this tag refers to (only looked up, not parsed)

getRawBufferback to summary
public final byte[] getRawBuffer()

Obtain the raw unparsed tag body (NOTE - THIS IS NOT A COPY).

This method is exposed only to provide very fast, efficient access to this tag's message buffer. Applications relying on this buffer should be very careful to ensure they do not modify its contents during their use of it.

Returns:byte[]

the raw unparsed tag body. This is NOT A COPY. Do not alter the returned array.

Since
5.11
getRawGpgSignatureback to summary
public final byte[] getRawGpgSignature()

Parse the GPG signature from the raw buffer.

Returns:byte[]

contents of the GPG signature; null if the tag was not signed.

Annotations
@Nullable
Since
5.11
getShortMessageback to summary
public final String getShortMessage()

Parse the tag message and return the first "line" of it.

The first line is everything up to the first pair of LFs. This is the "oneline" format, suitable for output in a single line display.

This method parses and returns the message portion of the tag buffer, after taking the tag's character set into account and decoding the buffer using that character set. This method is a fairly expensive operation and produces a new string on each invocation.

Returns:String

decoded tag message as a string. Never null. The returned string does not contain any LFs, even if the first paragraph spanned multiple lines. Embedded LFs are converted to spaces.

getSignatureStartback to summary
private int getSignatureStart()
getTaggerIdentback to summary
public final PersonIdent getTaggerIdent()

Parse the tagger identity from the raw buffer.

This method parses and returns the content of the tagger line, after taking the tag's character set into account and decoding the tagger name and email address. This method is fairly expensive and produces a new PersonIdent instance on each invocation. Callers should invoke this method only if they are certain they will be outputting the result, and should cache the return value for as long as necessary to use all information from it.

Returns:PersonIdent

identity of the tagger (name, email) and the time the tag was made by the tagger; null if no tagger line was found.

getTagNameback to summary
public final String getTagName()

Get the name of this tag, from the tag header.

Returns:String

name of the tag, according to the tag header.

getTypeback to summary
public final int getType()

Implements abstract org.eclipse.jgit.revwalk.RevObject.getType.

Doc from org.eclipse.jgit.revwalk.RevObject.getType.

Get Git object type. See org.eclipse.jgit.lib.Constants.

Returns:int

object type

Annotations
@Override
guessEncodingback to summary
private Charset guessEncoding()
nextStartback to summary
private static int nextStart(byte[] prefix, byte[] buffer, int from)
parseback to summary
public static RevTag parse(byte[] raw) throws CorruptObjectException

Parse an annotated tag from its canonical format. This method constructs a temporary revision pool, parses the tag as supplied, and returns it to the caller. Since the tag was built inside of a private revision pool its object pointer will be initialized, but will not have its headers loaded. Applications are discouraged from using this API. Callers usually need more than one object. Use org.eclipse.jgit.revwalk.RevWalk#parseTag(AnyObjectId) to obtain a RevTag from an existing repository.

Parameters
raw:byte[]

the canonical formatted tag to be parsed.

Returns:RevTag

the parsed tag, in an isolated revision pool that is not available to the caller.

Exceptions
CorruptObjectException:
the tag contains a malformed header that cannot be handled.
parseback to summary
public static RevTag parse(RevWalk rw, byte[] raw) throws CorruptObjectException

Parse an annotated tag from its canonical format.

This method inserts the tag directly into the caller supplied revision pool, making it appear as though the tag exists in the repository, even if it doesn't. The repository under the pool is not affected.

The body of the tag (message, tagger, signature) is always retained in the returned RevTag, even if the supplied RevWalk has been configured with setRetainBody(false).

Parameters
rw:RevWalk

the revision pool to allocate the tag within. The tag's object pointer will be obtained from this pool.

raw:byte[]

the canonical formatted tag to be parsed. This buffer will be retained by the returned RevTag and must not be modified by the caller.

Returns:RevTag

the parsed tag, in an isolated revision pool that is not available to the caller.

Exceptions
CorruptObjectException:
the tag contains a malformed header that cannot be handled.
parseBodyback to summary
pack-priv void parseBody(RevWalk walk) throws MissingObjectException, IncorrectObjectTypeException, IOException

Implements abstract org.eclipse.jgit.revwalk.RevObject.parseBody.

Annotations
@Override
parseCanonicalback to summary
pack-priv void parseCanonical(RevWalk walk, byte[] rawTag) throws CorruptObjectException
parseHeadersback to summary
pack-priv void parseHeaders(RevWalk walk) throws MissingObjectException, IncorrectObjectTypeException, IOException

Implements abstract org.eclipse.jgit.revwalk.RevObject.parseHeaders.

Annotations
@Override