Class Constants
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
Binary value for custom merger.static final String
Diff attribute.static final String
Key for filters in .gitattributesstatic final String
clean command name, used to call filter driverstatic final String
smudge command name, used to call filter driverstatic final String
Merge attribute.static final String
Builtin filter commands start with this prefixstatic final String
Deprecated.static final Charset
Deprecated.UseStandardCharsets.UTF_8
directly instead.static final String
name of the file containing the ID of a cherry pick commit in case of conflictsstatic final String
Name of the file in which git commands and hooks store and read the message prepared for the upcoming commit.static final String
Default name for the Git repository configurationstatic final String
Default remote name used by clone, push and fetch operationsstatic final String
The default extension for local bundle filesstatic final String
Default name for the Git repository directorystatic final String
Name of the attributes filestatic final String
A bare repository typically ends with this stringstatic final String
Name of the ignore filestatic final String
Name of the submodules filestatic final ObjectId
Well-known object ID for the empty blob.static final ObjectId
Well-known object ID for the empty tree.private static final byte[]
private static final byte[]
private static final byte[]
private static final byte[]
static final String
Special name for the "FETCH_HEAD" symbolic-ref.static final String
The environment variable that tells us where to look for objects, besides the default objects directory.static final String
The environment variable that contains the author's emailstatic final String
The environment variable that contains the author's namestatic final String
The environment variable that limits how close to the root of the file systems JGit will traverse when looking for a repository root.static final String
The environment variable that contains the commiter's emailstatic final String
The environment variable that contains the commiter's namestatic final String
The environment variable that blocks use of the system config filestatic final String
The environment variable that tells us which directory is the ".git" directorystatic final String
The environment variable that tells us which file holds the Git index.static final String
The environment variable that tells us where objects are storedstatic final String
The environment variable that tells us which directory is the working directory.static final String
Prefix of the first line in a ".git" filestatic final String
A gitignore file nameprivate static final String
Hash function used natively by Git for all objects.static final String
Special name for the "HEAD" symbolic-ref.static final String
Name of the folder (inside gitDir) where the hooks are stored.static final String
Info alternates file (goes under OBJECTS)static final String
Attributes-override-filestatic final String
Excludes-filestatic final String
HTTP alternates file (goes under OBJECTS)static final String
Info refs folderstatic final String
Suffix of lock file namestatic final String
Logs folder namestatic final String
Default main branch namestatic final String
name of the file containing the IDs of the parents of a merge commitstatic final String
name of the file containing the commit msg for a merge commitstatic final String
Name of the folder (inside gitDir) where submodules are storedstatic final int
An unknown or invalid object type code.static final int
In-pack object type: blob.static final int
In-pack object type: commit.static final int
In-pack object type: extended types.static final int
In-pack object type: offset deltastatic final int
In-pack object type: reference deltastatic final int
In-pack object type: annotated tag.static final int
In-pack object type: tree.static final int
In-pack object type: reserved for future use.static final int
The historic length of an abbreviated Git object hash string.static final int
A Git object hash is 160 bits, i.e.static final int
A Git object can be expressed as a 40 character string of hexadecimal digits.static final String
Objects folder namestatic final String
name of the ref ORIG_HEAD used by certain commands to store the original value of HEADstatic final String
The system property that contains the system user namestatic final String
The system property that contains the system user namestatic final byte[]
Pack file signature that occurs at file header - identifies file as Git packfile formatted.static final String
Packed refs filestatic final String
Prefix for branch refsstatic final String
Prefix for notes refsstatic final String
Standard notes refstatic final String
Prefix for any refstatic final String
Prefix for remotes refsstatic final String
Standard stash refstatic final String
Prefix for tag refsstatic final String
Reftable folder namestatic final String
name of the file containing the ID of a revert commit in case of conflictsstatic final String
Name of the .git/shallow filestatic final String
Beginning of the common "Signed-off-by: " commit message linestatic final String
name of the file containing the commit msg for a squash commitstatic final String
Default stash branch namestatic final String
Reftable table list name.static final String
Text string that identifies an object as a blob.static final String
Text string that identifies an object as a commit.static final String
Text string that identifies an object as an annotated tag.static final String
Text string that identifies an object as a tree.static final String
Default value for the user name if no other information is availablestatic final String
The key of the XDG_CONFIG_HOME directory defined in the XDG base directory specification, see {@link "https://wiki.archlinux.org/index.php/XDG_Base_Directory"} -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic int
decodeTypeString
(AnyObjectId id, byte[] typeString, byte endMark, MutableInteger offset) Parse an encoded type string into a type constant.static byte[]
Convert a string to a byte array in the standard character encoding.static byte[]
encodeASCII
(long s) Convert an integer into its decimal representation.static byte[]
Convert a string to US-ASCII encoding.static byte[]
encodedTypeString
(int typeCode) Convert an OBJ_* type constant to an ASCII encoded string constant.static MessageDigest
Create a new digest function for objects.static String
typeString
(int typeCode) Convert an OBJ_* type constant to a TYPE_* type constant.
-
Field Details
-
HASH_FUNCTION
Hash function used natively by Git for all objects.- See Also:
-
OBJECT_ID_LENGTH
public static final int OBJECT_ID_LENGTHA Git object hash is 160 bits, i.e. 20 bytes.Changing this assumption is not going to be as easy as changing this declaration.
- See Also:
-
OBJECT_ID_STRING_LENGTH
public static final int OBJECT_ID_STRING_LENGTHA Git object can be expressed as a 40 character string of hexadecimal digits.- See Also:
-
OBJECT_ID_ABBREV_STRING_LENGTH
public static final int OBJECT_ID_ABBREV_STRING_LENGTHThe historic length of an abbreviated Git object hash string. Git 2.11 changed this static number to a dynamically calculated one that scales as the repository grows.- Since:
- 6.1
- See Also:
-
HEAD
Special name for the "HEAD" symbolic-ref.- See Also:
-
FETCH_HEAD
Special name for the "FETCH_HEAD" symbolic-ref.- See Also:
-
TYPE_COMMIT
Text string that identifies an object as a commit.Commits connect trees into a string of project histories, where each commit is an assertion that the best way to continue is to use this other tree (set of files).
- See Also:
-
TYPE_BLOB
Text string that identifies an object as a blob.Blobs store whole file revisions. They are used for any user file, as well as for symlinks. Blobs form the bulk of any project's storage space.
- See Also:
-
TYPE_TREE
Text string that identifies an object as a tree.Trees attach object ids (hashes) to names and file modes. The normal use for a tree is to store a version of a directory and its contents.
- See Also:
-
TYPE_TAG
Text string that identifies an object as an annotated tag.Annotated tags store a pointer to any other object, and an additional message. It is most commonly used to record a stable release of the project.
- See Also:
-
ENCODED_TYPE_COMMIT
private static final byte[] ENCODED_TYPE_COMMIT -
ENCODED_TYPE_BLOB
private static final byte[] ENCODED_TYPE_BLOB -
ENCODED_TYPE_TREE
private static final byte[] ENCODED_TYPE_TREE -
ENCODED_TYPE_TAG
private static final byte[] ENCODED_TYPE_TAG -
OBJ_BAD
public static final int OBJ_BADAn unknown or invalid object type code.- See Also:
-
OBJ_EXT
public static final int OBJ_EXTIn-pack object type: extended types.This header code is reserved for future expansion. It is currently undefined/unsupported.
- See Also:
-
OBJ_COMMIT
public static final int OBJ_COMMITIn-pack object type: commit.Indicates the associated object is a commit.
This constant is fixed and is defined by the Git packfile format.
- See Also:
-
OBJ_TREE
public static final int OBJ_TREEIn-pack object type: tree.Indicates the associated object is a tree.
This constant is fixed and is defined by the Git packfile format.
- See Also:
-
OBJ_BLOB
public static final int OBJ_BLOBIn-pack object type: blob.Indicates the associated object is a blob.
This constant is fixed and is defined by the Git packfile format.
- See Also:
-
OBJ_TAG
public static final int OBJ_TAGIn-pack object type: annotated tag.Indicates the associated object is an annotated tag.
This constant is fixed and is defined by the Git packfile format.
- See Also:
-
OBJ_TYPE_5
public static final int OBJ_TYPE_5In-pack object type: reserved for future use.- See Also:
-
OBJ_OFS_DELTA
public static final int OBJ_OFS_DELTAIn-pack object type: offset deltaObjects stored with this type actually have a different type which must be obtained from their delta base object. Delta objects store only the changes needed to apply to the base object in order to recover the original object.
An offset delta uses a negative offset from the start of this object to refer to its delta base. The base object must exist in this packfile (even in the case of a thin pack).
This constant is fixed and is defined by the Git packfile format.
- See Also:
-
OBJ_REF_DELTA
public static final int OBJ_REF_DELTAIn-pack object type: reference deltaObjects stored with this type actually have a different type which must be obtained from their delta base object. Delta objects store only the changes needed to apply to the base object in order to recover the original object.
A reference delta uses a full object id (hash) to reference the delta base. The base object is allowed to be omitted from the packfile, but only in the case of a thin pack being transferred over the network.
This constant is fixed and is defined by the Git packfile format.
- See Also:
-
PACK_SIGNATURE
public static final byte[] PACK_SIGNATUREPack file signature that occurs at file header - identifies file as Git packfile formatted.This constant is fixed and is defined by the Git packfile format.
-
CHARSET
Deprecated.UseStandardCharsets.UTF_8
directly instead.Native character encoding for commit messages, file names... -
CHARACTER_ENCODING
Deprecated.UseStandardCharsets.UTF_8
directly instead.Native character encoding for commit messages, file names... -
MASTER
Default main branch name- See Also:
-
STASH
Default stash branch name- See Also:
-
R_HEADS
Prefix for branch refs- See Also:
-
R_REMOTES
Prefix for remotes refs- See Also:
-
R_TAGS
Prefix for tag refs- See Also:
-
R_NOTES
Prefix for notes refs- See Also:
-
R_NOTES_COMMITS
Standard notes ref- See Also:
-
R_REFS
Prefix for any ref- See Also:
-
R_STASH
Standard stash ref- See Also:
-
LOGS
Logs folder name- See Also:
-
OBJECTS
Objects folder name- Since:
- 5.5
- See Also:
-
REFTABLE
Reftable folder name- Since:
- 5.6
- See Also:
-
TABLES_LIST
Reftable table list name.- Since:
- 5.6.2
- See Also:
-
INFO_REFS
Info refs folder- See Also:
-
INFO_ALTERNATES
Info alternates file (goes under OBJECTS)- Since:
- 5.5
- See Also:
-
INFO_HTTP_ALTERNATES
HTTP alternates file (goes under OBJECTS)- Since:
- 5.5
- See Also:
-
PACKED_REFS
Packed refs file- See Also:
-
INFO_EXCLUDE
Excludes-file- Since:
- 3.0
- See Also:
-
INFO_ATTRIBUTES
Attributes-override-file- Since:
- 4.2
- See Also:
-
OS_USER_DIR
The system property that contains the system user name- Since:
- 3.6
- See Also:
-
OS_USER_NAME_KEY
The system property that contains the system user name- See Also:
-
GIT_AUTHOR_NAME_KEY
The environment variable that contains the author's name- See Also:
-
GIT_AUTHOR_EMAIL_KEY
The environment variable that contains the author's email- See Also:
-
GIT_COMMITTER_NAME_KEY
The environment variable that contains the commiter's name- See Also:
-
GIT_COMMITTER_EMAIL_KEY
The environment variable that contains the commiter's email- See Also:
-
GIT_CONFIG_NOSYSTEM_KEY
The environment variable that blocks use of the system config file- Since:
- 3.3
- See Also:
-
XDG_CONFIG_HOME
The key of the XDG_CONFIG_HOME directory defined in the XDG base directory specification, see {@link "https://wiki.archlinux.org/index.php/XDG_Base_Directory"}- Since:
- 5.5.2
- See Also:
-
GIT_CEILING_DIRECTORIES_KEY
The environment variable that limits how close to the root of the file systems JGit will traverse when looking for a repository root.- See Also:
-
GIT_DIR_KEY
The environment variable that tells us which directory is the ".git" directory- See Also:
-
GIT_WORK_TREE_KEY
The environment variable that tells us which directory is the working directory.- See Also:
-
GIT_INDEX_FILE_KEY
The environment variable that tells us which file holds the Git index.- See Also:
-
GIT_OBJECT_DIRECTORY_KEY
The environment variable that tells us where objects are stored- See Also:
-
GIT_ALTERNATE_OBJECT_DIRECTORIES_KEY
The environment variable that tells us where to look for objects, besides the default objects directory.- See Also:
-
UNKNOWN_USER_DEFAULT
Default value for the user name if no other information is available- See Also:
-
SIGNED_OFF_BY_TAG
Beginning of the common "Signed-off-by: " commit message line- See Also:
-
GITIGNORE_FILENAME
A gitignore file name- See Also:
-
DEFAULT_REMOTE_NAME
Default remote name used by clone, push and fetch operations- See Also:
-
DOT_GIT
Default name for the Git repository directory- See Also:
-
CONFIG
Default name for the Git repository configuration- See Also:
-
DOT_GIT_EXT
A bare repository typically ends with this string- See Also:
-
DOT_BUNDLE_EXT
The default extension for local bundle files- Since:
- 5.8
- See Also:
-
DOT_GIT_ATTRIBUTES
Name of the attributes file- Since:
- 3.7
- See Also:
-
ATTR_FILTER
Key for filters in .gitattributes- Since:
- 4.2
- See Also:
-
ATTR_FILTER_TYPE_CLEAN
clean command name, used to call filter driver- Since:
- 4.2
- See Also:
-
ATTR_FILTER_TYPE_SMUDGE
smudge command name, used to call filter driver- Since:
- 4.2
- See Also:
-
BUILTIN_FILTER_PREFIX
Builtin filter commands start with this prefix- Since:
- 4.6
- See Also:
-
DOT_GIT_IGNORE
Name of the ignore file- See Also:
-
DOT_GIT_MODULES
Name of the submodules file- See Also:
-
SHALLOW
Name of the .git/shallow file- See Also:
-
GITDIR
Prefix of the first line in a ".git" file- Since:
- 3.6
- See Also:
-
MODULES
Name of the folder (inside gitDir) where submodules are stored- Since:
- 3.6
- See Also:
-
HOOKS
Name of the folder (inside gitDir) where the hooks are stored.- Since:
- 3.7
- See Also:
-
ATTR_MERGE
Merge attribute.- Since:
- 4.9
- See Also:
-
ATTR_DIFF
Diff attribute.- Since:
- 4.11
- See Also:
-
ATTR_BUILTIN_BINARY_MERGER
Binary value for custom merger.- Since:
- 4.9
- See Also:
-
MERGE_MSG
name of the file containing the commit msg for a merge commit- See Also:
-
MERGE_HEAD
name of the file containing the IDs of the parents of a merge commit- See Also:
-
CHERRY_PICK_HEAD
name of the file containing the ID of a cherry pick commit in case of conflicts- See Also:
-
SQUASH_MSG
name of the file containing the commit msg for a squash commit- See Also:
-
REVERT_HEAD
name of the file containing the ID of a revert commit in case of conflicts- See Also:
-
ORIG_HEAD
name of the ref ORIG_HEAD used by certain commands to store the original value of HEAD- See Also:
-
COMMIT_EDITMSG
Name of the file in which git commands and hooks store and read the message prepared for the upcoming commit.- Since:
- 4.0
- See Also:
-
EMPTY_BLOB_ID
Well-known object ID for the empty blob.- Since:
- 0.9.1
-
EMPTY_TREE_ID
Well-known object ID for the empty tree.- Since:
- 5.1
-
LOCK_SUFFIX
Suffix of lock file name- Since:
- 4.7
- See Also:
-
-
Constructor Details
-
Constants
private Constants()
-
-
Method Details
-
newMessageDigest
Create a new digest function for objects.- Returns:
- a new digest object.
- Throws:
RuntimeException
- this Java virtual machine does not support the required hash function. Very unlikely given that JGit uses a hash function that is in the Java reference specification.
-
typeString
Convert an OBJ_* type constant to a TYPE_* type constant.- Parameters:
typeCode
- the type code, from a pack representation.- Returns:
- the canonical string name of this type.
-
encodedTypeString
public static byte[] encodedTypeString(int typeCode) Convert an OBJ_* type constant to an ASCII encoded string constant.The ASCII encoded string is often the canonical representation of the type within a loose object header, or within a tag header.
- Parameters:
typeCode
- the type code, from a pack representation.- Returns:
- the canonical ASCII encoded name of this type.
-
decodeTypeString
public static int decodeTypeString(AnyObjectId id, byte[] typeString, byte endMark, MutableInteger offset) throws CorruptObjectException Parse an encoded type string into a type constant.- Parameters:
id
- object id this type string came from; may be null if that is not known at the time the parse is occurring.typeString
- string version of the type code.endMark
- character immediately following the type string. Usually ' ' (space) or '\n' (line feed).offset
- position withintypeString
where the parse should start. Updated with the new position (just pastendMark
when the parse is successful.- Returns:
- a type code constant (one of
OBJ_BLOB
,OBJ_COMMIT
,OBJ_TAG
,OBJ_TREE
. - Throws:
CorruptObjectException
- there is no valid type identified bytypeString
.
-
encodeASCII
public static byte[] encodeASCII(long s) Convert an integer into its decimal representation.- Parameters:
s
- the integer to convert.- Returns:
- a decimal representation of the input integer. The returned array is the smallest array that will hold the value.
-
encodeASCII
Convert a string to US-ASCII encoding.- Parameters:
s
- the string to convert. Must not contain any characters over 127 (outside of 7-bit ASCII).- Returns:
- a byte array of the same length as the input string, holding the same characters, in the same order.
- Throws:
IllegalArgumentException
- the input string contains one or more characters outside of the 7-bit ASCII character space.
-
encode
Convert a string to a byte array in the standard character encoding.- Parameters:
str
- the string to convert. May contain any Unicode characters.- Returns:
- a byte array representing the requested string, encoded using the default character encoding (UTF-8).
- See Also:
-
StandardCharsets.UTF_8
directly instead.