Constants.java

  1. /*
  2.  * Copyright (C) 2008, Google Inc.
  3.  * Copyright (C) 2008, Robin Rosenberg <robin.rosenberg@dewire.com>
  4.  * Copyright (C) 2006-2017, Shawn O. Pearce <spearce@spearce.org> and others
  5.  *
  6.  * This program and the accompanying materials are made available under the
  7.  * terms of the Eclipse Distribution License v. 1.0 which is available at
  8.  * https://www.eclipse.org/org/documents/edl-v10.php.
  9.  *
  10.  * SPDX-License-Identifier: BSD-3-Clause
  11.  */

  12. package org.eclipse.jgit.lib;

  13. import static java.nio.charset.StandardCharsets.UTF_8;

  14. import java.nio.ByteBuffer;
  15. import java.nio.charset.Charset;
  16. import java.security.MessageDigest;
  17. import java.security.NoSuchAlgorithmException;
  18. import java.text.MessageFormat;

  19. import org.eclipse.jgit.errors.CorruptObjectException;
  20. import org.eclipse.jgit.internal.JGitText;
  21. import org.eclipse.jgit.util.MutableInteger;

  22. /**
  23.  * Misc. constants and helpers used throughout JGit.
  24.  */
  25. @SuppressWarnings("nls")
  26. public final class Constants {
  27.     /** Hash function used natively by Git for all objects. */
  28.     private static final String HASH_FUNCTION = "SHA-1";

  29.     /**
  30.      * A Git object hash is 160 bits, i.e. 20 bytes.
  31.      * <p>
  32.      * Changing this assumption is not going to be as easy as changing this
  33.      * declaration.
  34.      */
  35.     public static final int OBJECT_ID_LENGTH = 20;

  36.     /**
  37.      * A Git object can be expressed as a 40 character string of hexadecimal
  38.      * digits.
  39.      *
  40.      * @see #OBJECT_ID_LENGTH
  41.      */
  42.     public static final int OBJECT_ID_STRING_LENGTH = OBJECT_ID_LENGTH * 2;

  43.     /** Special name for the "HEAD" symbolic-ref. */
  44.     public static final String HEAD = "HEAD";

  45.     /** Special name for the "FETCH_HEAD" symbolic-ref. */
  46.     public static final String FETCH_HEAD = "FETCH_HEAD";

  47.     /**
  48.      * Text string that identifies an object as a commit.
  49.      * <p>
  50.      * Commits connect trees into a string of project histories, where each
  51.      * commit is an assertion that the best way to continue is to use this other
  52.      * tree (set of files).
  53.      */
  54.     public static final String TYPE_COMMIT = "commit";

  55.     /**
  56.      * Text string that identifies an object as a blob.
  57.      * <p>
  58.      * Blobs store whole file revisions. They are used for any user file, as
  59.      * well as for symlinks. Blobs form the bulk of any project's storage space.
  60.      */
  61.     public static final String TYPE_BLOB = "blob";

  62.     /**
  63.      * Text string that identifies an object as a tree.
  64.      * <p>
  65.      * Trees attach object ids (hashes) to names and file modes. The normal use
  66.      * for a tree is to store a version of a directory and its contents.
  67.      */
  68.     public static final String TYPE_TREE = "tree";

  69.     /**
  70.      * Text string that identifies an object as an annotated tag.
  71.      * <p>
  72.      * Annotated tags store a pointer to any other object, and an additional
  73.      * message. It is most commonly used to record a stable release of the
  74.      * project.
  75.      */
  76.     public static final String TYPE_TAG = "tag";

  77.     private static final byte[] ENCODED_TYPE_COMMIT = encodeASCII(TYPE_COMMIT);

  78.     private static final byte[] ENCODED_TYPE_BLOB = encodeASCII(TYPE_BLOB);

  79.     private static final byte[] ENCODED_TYPE_TREE = encodeASCII(TYPE_TREE);

  80.     private static final byte[] ENCODED_TYPE_TAG = encodeASCII(TYPE_TAG);

  81.     /** An unknown or invalid object type code. */
  82.     public static final int OBJ_BAD = -1;

  83.     /**
  84.      * In-pack object type: extended types.
  85.      * <p>
  86.      * This header code is reserved for future expansion. It is currently
  87.      * undefined/unsupported.
  88.      */
  89.     public static final int OBJ_EXT = 0;

  90.     /**
  91.      * In-pack object type: commit.
  92.      * <p>
  93.      * Indicates the associated object is a commit.
  94.      * <p>
  95.      * <b>This constant is fixed and is defined by the Git packfile format.</b>
  96.      *
  97.      * @see #TYPE_COMMIT
  98.      */
  99.     public static final int OBJ_COMMIT = 1;

  100.     /**
  101.      * In-pack object type: tree.
  102.      * <p>
  103.      * Indicates the associated object is a tree.
  104.      * <p>
  105.      * <b>This constant is fixed and is defined by the Git packfile format.</b>
  106.      *
  107.      * @see #TYPE_BLOB
  108.      */
  109.     public static final int OBJ_TREE = 2;

  110.     /**
  111.      * In-pack object type: blob.
  112.      * <p>
  113.      * Indicates the associated object is a blob.
  114.      * <p>
  115.      * <b>This constant is fixed and is defined by the Git packfile format.</b>
  116.      *
  117.      * @see #TYPE_BLOB
  118.      */
  119.     public static final int OBJ_BLOB = 3;

  120.     /**
  121.      * In-pack object type: annotated tag.
  122.      * <p>
  123.      * Indicates the associated object is an annotated tag.
  124.      * <p>
  125.      * <b>This constant is fixed and is defined by the Git packfile format.</b>
  126.      *
  127.      * @see #TYPE_TAG
  128.      */
  129.     public static final int OBJ_TAG = 4;

  130.     /** In-pack object type: reserved for future use. */
  131.     public static final int OBJ_TYPE_5 = 5;

  132.     /**
  133.      * In-pack object type: offset delta
  134.      * <p>
  135.      * Objects stored with this type actually have a different type which must
  136.      * be obtained from their delta base object. Delta objects store only the
  137.      * changes needed to apply to the base object in order to recover the
  138.      * original object.
  139.      * <p>
  140.      * An offset delta uses a negative offset from the start of this object to
  141.      * refer to its delta base. The base object must exist in this packfile
  142.      * (even in the case of a thin pack).
  143.      * <p>
  144.      * <b>This constant is fixed and is defined by the Git packfile format.</b>
  145.      */
  146.     public static final int OBJ_OFS_DELTA = 6;

  147.     /**
  148.      * In-pack object type: reference delta
  149.      * <p>
  150.      * Objects stored with this type actually have a different type which must
  151.      * be obtained from their delta base object. Delta objects store only the
  152.      * changes needed to apply to the base object in order to recover the
  153.      * original object.
  154.      * <p>
  155.      * A reference delta uses a full object id (hash) to reference the delta
  156.      * base. The base object is allowed to be omitted from the packfile, but
  157.      * only in the case of a thin pack being transferred over the network.
  158.      * <p>
  159.      * <b>This constant is fixed and is defined by the Git packfile format.</b>
  160.      */
  161.     public static final int OBJ_REF_DELTA = 7;

  162.     /**
  163.      * Pack file signature that occurs at file header - identifies file as Git
  164.      * packfile formatted.
  165.      * <p>
  166.      * <b>This constant is fixed and is defined by the Git packfile format.</b>
  167.      */
  168.     public static final byte[] PACK_SIGNATURE = { 'P', 'A', 'C', 'K' };

  169.     /**
  170.      * Native character encoding for commit messages, file names...
  171.      *
  172.      * @deprecated Use {@link java.nio.charset.StandardCharsets#UTF_8} directly
  173.      *             instead.
  174.      */
  175.     @Deprecated
  176.     public static final Charset CHARSET;

  177.     /**
  178.      * Native character encoding for commit messages, file names...
  179.      *
  180.      * @deprecated Use {@link java.nio.charset.StandardCharsets#UTF_8} directly
  181.      *             instead.
  182.      */
  183.     @Deprecated
  184.     public static final String CHARACTER_ENCODING;

  185.     /** Default main branch name */
  186.     public static final String MASTER = "master";

  187.     /** Default stash branch name */
  188.     public static final String STASH = "stash";

  189.     /** Prefix for branch refs */
  190.     public static final String R_HEADS = "refs/heads/";

  191.     /** Prefix for remotes refs */
  192.     public static final String R_REMOTES = "refs/remotes/";

  193.     /** Prefix for tag refs */
  194.     public static final String R_TAGS = "refs/tags/";

  195.     /** Prefix for notes refs */
  196.     public static final String R_NOTES = "refs/notes/";

  197.     /** Standard notes ref */
  198.     public static final String R_NOTES_COMMITS = R_NOTES + "commits";

  199.     /** Prefix for any ref */
  200.     public static final String R_REFS = "refs/";

  201.     /** Standard stash ref */
  202.     public static final String R_STASH = R_REFS + STASH;

  203.     /** Logs folder name */
  204.     public static final String LOGS = "logs";

  205.     /**
  206.      * Objects folder name
  207.      * @since 5.5
  208.      */
  209.     public static final String OBJECTS = "objects";

  210.     /**
  211.      * Reftable folder name
  212.      * @since 5.6
  213.      */
  214.     public static final String REFTABLE = "reftable";

  215.     /**
  216.      * Reftable table list name.
  217.      * @since 5.6.2
  218.      */
  219.     public static final String TABLES_LIST = "tables.list";

  220.     /** Info refs folder */
  221.     public static final String INFO_REFS = "info/refs";

  222.     /**
  223.      * Info alternates file (goes under OBJECTS)
  224.      * @since 5.5
  225.      */
  226.     public static final String INFO_ALTERNATES = "info/alternates";

  227.     /**
  228.      * HTTP alternates file (goes under OBJECTS)
  229.      * @since 5.5
  230.      */
  231.     public static final String INFO_HTTP_ALTERNATES = "info/http-alternates";

  232.     /** Packed refs file */
  233.     public static final String PACKED_REFS = "packed-refs";

  234.     /**
  235.      * Excludes-file
  236.      *
  237.      * @since 3.0
  238.      */
  239.     public static final String INFO_EXCLUDE = "info/exclude";

  240.     /**
  241.      * Attributes-override-file
  242.      *
  243.      * @since 4.2
  244.      */
  245.     public static final String INFO_ATTRIBUTES = "info/attributes";

  246.     /**
  247.      * The system property that contains the system user name
  248.      *
  249.      * @since 3.6
  250.      */
  251.     public static final String OS_USER_DIR = "user.dir";

  252.     /** The system property that contains the system user name */
  253.     public static final String OS_USER_NAME_KEY = "user.name";

  254.     /** The environment variable that contains the author's name */
  255.     public static final String GIT_AUTHOR_NAME_KEY = "GIT_AUTHOR_NAME";

  256.     /** The environment variable that contains the author's email */
  257.     public static final String GIT_AUTHOR_EMAIL_KEY = "GIT_AUTHOR_EMAIL";

  258.     /** The environment variable that contains the commiter's name */
  259.     public static final String GIT_COMMITTER_NAME_KEY = "GIT_COMMITTER_NAME";

  260.     /** The environment variable that contains the commiter's email */
  261.     public static final String GIT_COMMITTER_EMAIL_KEY = "GIT_COMMITTER_EMAIL";

  262.     /**
  263.      * The environment variable that blocks use of the system config file
  264.      *
  265.      * @since 3.3
  266.      */
  267.     public static final String GIT_CONFIG_NOSYSTEM_KEY = "GIT_CONFIG_NOSYSTEM";

  268.     /**
  269.      * The key of the XDG_CONFIG_HOME directory defined in the XDG base
  270.      * directory specification, see
  271.      * {@link "https://wiki.archlinux.org/index.php/XDG_Base_Directory"}
  272.      *
  273.      * @since 5.5.2
  274.      */
  275.     public static final String XDG_CONFIG_HOME = "XDG_CONFIG_HOME";

  276.     /**
  277.      * The environment variable that limits how close to the root of the file
  278.      * systems JGit will traverse when looking for a repository root.
  279.      */
  280.     public static final String GIT_CEILING_DIRECTORIES_KEY = "GIT_CEILING_DIRECTORIES";

  281.     /**
  282.      * The environment variable that tells us which directory is the ".git"
  283.      * directory
  284.      */
  285.     public static final String GIT_DIR_KEY = "GIT_DIR";

  286.     /**
  287.      * The environment variable that tells us which directory is the working
  288.      * directory.
  289.      */
  290.     public static final String GIT_WORK_TREE_KEY = "GIT_WORK_TREE";

  291.     /**
  292.      * The environment variable that tells us which file holds the Git index.
  293.      */
  294.     public static final String GIT_INDEX_FILE_KEY = "GIT_INDEX_FILE";

  295.     /**
  296.      * The environment variable that tells us where objects are stored
  297.      */
  298.     public static final String GIT_OBJECT_DIRECTORY_KEY = "GIT_OBJECT_DIRECTORY";

  299.     /**
  300.      * The environment variable that tells us where to look for objects, besides
  301.      * the default objects directory.
  302.      */
  303.     public static final String GIT_ALTERNATE_OBJECT_DIRECTORIES_KEY = "GIT_ALTERNATE_OBJECT_DIRECTORIES";

  304.     /** Default value for the user name if no other information is available */
  305.     public static final String UNKNOWN_USER_DEFAULT = "unknown-user";

  306.     /** Beginning of the common "Signed-off-by: " commit message line */
  307.     public static final String SIGNED_OFF_BY_TAG = "Signed-off-by: ";

  308.     /** A gitignore file name */
  309.     public static final String GITIGNORE_FILENAME = ".gitignore";

  310.     /** Default remote name used by clone, push and fetch operations */
  311.     public static final String DEFAULT_REMOTE_NAME = "origin";

  312.     /** Default name for the Git repository directory */
  313.     public static final String DOT_GIT = ".git";

  314.     /** Default name for the Git repository configuration */
  315.     public static final String CONFIG = "config";

  316.     /** A bare repository typically ends with this string */
  317.     public static final String DOT_GIT_EXT = ".git";

  318.     /**
  319.      * The default extension for local bundle files
  320.      *
  321.      * @since 5.8
  322.      */
  323.     public static final String DOT_BUNDLE_EXT = ".bundle";

  324.     /**
  325.      * Name of the attributes file
  326.      *
  327.      * @since 3.7
  328.      */
  329.     public static final String DOT_GIT_ATTRIBUTES = ".gitattributes";

  330.     /**
  331.      * Key for filters in .gitattributes
  332.      *
  333.      * @since 4.2
  334.      */
  335.     public static final String ATTR_FILTER = "filter";

  336.     /**
  337.      * clean command name, used to call filter driver
  338.      *
  339.      * @since 4.2
  340.      */
  341.     public static final String ATTR_FILTER_TYPE_CLEAN = "clean";

  342.     /**
  343.      * smudge command name, used to call filter driver
  344.      *
  345.      * @since 4.2
  346.      */
  347.     public static final String ATTR_FILTER_TYPE_SMUDGE = "smudge";

  348.     /**
  349.      * Builtin filter commands start with this prefix
  350.      *
  351.      * @since 4.6
  352.      */
  353.     public static final String BUILTIN_FILTER_PREFIX = "jgit://builtin/";

  354.     /** Name of the ignore file */
  355.     public static final String DOT_GIT_IGNORE = ".gitignore";

  356.     /** Name of the submodules file */
  357.     public static final String DOT_GIT_MODULES = ".gitmodules";

  358.     /** Name of the .git/shallow file */
  359.     public static final String SHALLOW = "shallow";

  360.     /**
  361.      * Prefix of the first line in a ".git" file
  362.      *
  363.      * @since 3.6
  364.      */
  365.     public static final String GITDIR = "gitdir: ";

  366.     /**
  367.      * Name of the folder (inside gitDir) where submodules are stored
  368.      *
  369.      * @since 3.6
  370.      */
  371.     public static final String MODULES = "modules";

  372.     /**
  373.      * Name of the folder (inside gitDir) where the hooks are stored.
  374.      *
  375.      * @since 3.7
  376.      */
  377.     public static final String HOOKS = "hooks";

  378.     /**
  379.      * Merge attribute.
  380.      *
  381.      * @since 4.9
  382.      */
  383.     public static final String ATTR_MERGE = "merge"; //$NON-NLS-1$

  384.     /**
  385.      * Diff attribute.
  386.      *
  387.      * @since 4.11
  388.      */
  389.     public static final String ATTR_DIFF = "diff"; //$NON-NLS-1$

  390.     /**
  391.      * Binary value for custom merger.
  392.      *
  393.      * @since 4.9
  394.      */
  395.     public static final String ATTR_BUILTIN_BINARY_MERGER = "binary"; //$NON-NLS-1$

  396.     /**
  397.      * Create a new digest function for objects.
  398.      *
  399.      * @return a new digest object.
  400.      * @throws java.lang.RuntimeException
  401.      *             this Java virtual machine does not support the required hash
  402.      *             function. Very unlikely given that JGit uses a hash function
  403.      *             that is in the Java reference specification.
  404.      */
  405.     public static MessageDigest newMessageDigest() {
  406.         try {
  407.             return MessageDigest.getInstance(HASH_FUNCTION);
  408.         } catch (NoSuchAlgorithmException nsae) {
  409.             throw new RuntimeException(MessageFormat.format(
  410.                     JGitText.get().requiredHashFunctionNotAvailable, HASH_FUNCTION), nsae);
  411.         }
  412.     }

  413.     /**
  414.      * Convert an OBJ_* type constant to a TYPE_* type constant.
  415.      *
  416.      * @param typeCode the type code, from a pack representation.
  417.      * @return the canonical string name of this type.
  418.      */
  419.     public static String typeString(int typeCode) {
  420.         switch (typeCode) {
  421.         case OBJ_COMMIT:
  422.             return TYPE_COMMIT;
  423.         case OBJ_TREE:
  424.             return TYPE_TREE;
  425.         case OBJ_BLOB:
  426.             return TYPE_BLOB;
  427.         case OBJ_TAG:
  428.             return TYPE_TAG;
  429.         default:
  430.             throw new IllegalArgumentException(MessageFormat.format(
  431.                     JGitText.get().badObjectType, Integer.valueOf(typeCode)));
  432.         }
  433.     }

  434.     /**
  435.      * Convert an OBJ_* type constant to an ASCII encoded string constant.
  436.      * <p>
  437.      * The ASCII encoded string is often the canonical representation of
  438.      * the type within a loose object header, or within a tag header.
  439.      *
  440.      * @param typeCode the type code, from a pack representation.
  441.      * @return the canonical ASCII encoded name of this type.
  442.      */
  443.     public static byte[] encodedTypeString(int typeCode) {
  444.         switch (typeCode) {
  445.         case OBJ_COMMIT:
  446.             return ENCODED_TYPE_COMMIT;
  447.         case OBJ_TREE:
  448.             return ENCODED_TYPE_TREE;
  449.         case OBJ_BLOB:
  450.             return ENCODED_TYPE_BLOB;
  451.         case OBJ_TAG:
  452.             return ENCODED_TYPE_TAG;
  453.         default:
  454.             throw new IllegalArgumentException(MessageFormat.format(
  455.                     JGitText.get().badObjectType, Integer.valueOf(typeCode)));
  456.         }
  457.     }

  458.     /**
  459.      * Parse an encoded type string into a type constant.
  460.      *
  461.      * @param id
  462.      *            object id this type string came from; may be null if that is
  463.      *            not known at the time the parse is occurring.
  464.      * @param typeString
  465.      *            string version of the type code.
  466.      * @param endMark
  467.      *            character immediately following the type string. Usually ' '
  468.      *            (space) or '\n' (line feed).
  469.      * @param offset
  470.      *            position within <code>typeString</code> where the parse
  471.      *            should start. Updated with the new position (just past
  472.      *            <code>endMark</code> when the parse is successful.
  473.      * @return a type code constant (one of {@link #OBJ_BLOB},
  474.      *         {@link #OBJ_COMMIT}, {@link #OBJ_TAG}, {@link #OBJ_TREE}.
  475.      * @throws org.eclipse.jgit.errors.CorruptObjectException
  476.      *             there is no valid type identified by <code>typeString</code>.
  477.      */
  478.     public static int decodeTypeString(final AnyObjectId id,
  479.             final byte[] typeString, final byte endMark,
  480.             final MutableInteger offset) throws CorruptObjectException {
  481.         try {
  482.             int position = offset.value;
  483.             switch (typeString[position]) {
  484.             case 'b':
  485.                 if (typeString[position + 1] != 'l'
  486.                         || typeString[position + 2] != 'o'
  487.                         || typeString[position + 3] != 'b'
  488.                         || typeString[position + 4] != endMark)
  489.                     throw new CorruptObjectException(id, JGitText.get().corruptObjectInvalidType);
  490.                 offset.value = position + 5;
  491.                 return Constants.OBJ_BLOB;

  492.             case 'c':
  493.                 if (typeString[position + 1] != 'o'
  494.                         || typeString[position + 2] != 'm'
  495.                         || typeString[position + 3] != 'm'
  496.                         || typeString[position + 4] != 'i'
  497.                         || typeString[position + 5] != 't'
  498.                         || typeString[position + 6] != endMark)
  499.                     throw new CorruptObjectException(id, JGitText.get().corruptObjectInvalidType);
  500.                 offset.value = position + 7;
  501.                 return Constants.OBJ_COMMIT;

  502.             case 't':
  503.                 switch (typeString[position + 1]) {
  504.                 case 'a':
  505.                     if (typeString[position + 2] != 'g'
  506.                             || typeString[position + 3] != endMark)
  507.                         throw new CorruptObjectException(id, JGitText.get().corruptObjectInvalidType);
  508.                     offset.value = position + 4;
  509.                     return Constants.OBJ_TAG;

  510.                 case 'r':
  511.                     if (typeString[position + 2] != 'e'
  512.                             || typeString[position + 3] != 'e'
  513.                             || typeString[position + 4] != endMark)
  514.                         throw new CorruptObjectException(id, JGitText.get().corruptObjectInvalidType);
  515.                     offset.value = position + 5;
  516.                     return Constants.OBJ_TREE;

  517.                 default:
  518.                     throw new CorruptObjectException(id, JGitText.get().corruptObjectInvalidType);
  519.                 }

  520.             default:
  521.                 throw new CorruptObjectException(id, JGitText.get().corruptObjectInvalidType);
  522.             }
  523.         } catch (ArrayIndexOutOfBoundsException bad) {
  524.             CorruptObjectException coe = new CorruptObjectException(id,
  525.                     JGitText.get().corruptObjectInvalidType);
  526.             coe.initCause(bad);
  527.             throw coe;
  528.         }
  529.     }

  530.     /**
  531.      * Convert an integer into its decimal representation.
  532.      *
  533.      * @param s
  534.      *            the integer to convert.
  535.      * @return a decimal representation of the input integer. The returned array
  536.      *         is the smallest array that will hold the value.
  537.      */
  538.     public static byte[] encodeASCII(long s) {
  539.         return encodeASCII(Long.toString(s));
  540.     }

  541.     /**
  542.      * Convert a string to US-ASCII encoding.
  543.      *
  544.      * @param s
  545.      *            the string to convert. Must not contain any characters over
  546.      *            127 (outside of 7-bit ASCII).
  547.      * @return a byte array of the same length as the input string, holding the
  548.      *         same characters, in the same order.
  549.      * @throws java.lang.IllegalArgumentException
  550.      *             the input string contains one or more characters outside of
  551.      *             the 7-bit ASCII character space.
  552.      */
  553.     public static byte[] encodeASCII(String s) {
  554.         final byte[] r = new byte[s.length()];
  555.         for (int k = r.length - 1; k >= 0; k--) {
  556.             final char c = s.charAt(k);
  557.             if (c > 127)
  558.                 throw new IllegalArgumentException(MessageFormat.format(JGitText.get().notASCIIString, s));
  559.             r[k] = (byte) c;
  560.         }
  561.         return r;
  562.     }

  563.     /**
  564.      * Convert a string to a byte array in the standard character encoding.
  565.      *
  566.      * @param str
  567.      *            the string to convert. May contain any Unicode characters.
  568.      * @return a byte array representing the requested string, encoded using the
  569.      *         default character encoding (UTF-8).
  570.      * @see #CHARACTER_ENCODING
  571.      */
  572.     public static byte[] encode(String str) {
  573.         final ByteBuffer bb = UTF_8.encode(str);
  574.         final int len = bb.limit();
  575.         if (bb.hasArray() && bb.arrayOffset() == 0) {
  576.             final byte[] arr = bb.array();
  577.             if (arr.length == len)
  578.                 return arr;
  579.         }

  580.         final byte[] arr = new byte[len];
  581.         bb.get(arr);
  582.         return arr;
  583.     }

  584.     static {
  585.         if (OBJECT_ID_LENGTH != newMessageDigest().getDigestLength())
  586.             throw new LinkageError(JGitText.get().incorrectOBJECT_ID_LENGTH);
  587.         CHARSET = UTF_8;
  588.         CHARACTER_ENCODING = UTF_8.name();
  589.     }

  590.     /** name of the file containing the commit msg for a merge commit */
  591.     public static final String MERGE_MSG = "MERGE_MSG";

  592.     /** name of the file containing the IDs of the parents of a merge commit */
  593.     public static final String MERGE_HEAD = "MERGE_HEAD";

  594.     /** name of the file containing the ID of a cherry pick commit in case of conflicts */
  595.     public static final String CHERRY_PICK_HEAD = "CHERRY_PICK_HEAD";

  596.     /** name of the file containing the commit msg for a squash commit */
  597.     public static final String SQUASH_MSG = "SQUASH_MSG";

  598.     /** name of the file containing the ID of a revert commit in case of conflicts */
  599.     public static final String REVERT_HEAD = "REVERT_HEAD";

  600.     /**
  601.      * name of the ref ORIG_HEAD used by certain commands to store the original
  602.      * value of HEAD
  603.      */
  604.     public static final String ORIG_HEAD = "ORIG_HEAD";

  605.     /**
  606.      * Name of the file in which git commands and hooks store and read the
  607.      * message prepared for the upcoming commit.
  608.      *
  609.      * @since 4.0
  610.      */
  611.     public static final String COMMIT_EDITMSG = "COMMIT_EDITMSG";

  612.     /**
  613.      * Well-known object ID for the empty blob.
  614.      *
  615.      * @since 0.9.1
  616.      */
  617.     public static final ObjectId EMPTY_BLOB_ID = ObjectId
  618.             .fromString("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391");

  619.     /**
  620.      * Well-known object ID for the empty tree.
  621.      *
  622.      * @since 5.1
  623.      */
  624.     public static final ObjectId EMPTY_TREE_ID = ObjectId
  625.             .fromString("4b825dc642cb6eb9a060e54bf8d69288fbee4904");

  626.     /**
  627.      * Suffix of lock file name
  628.      *
  629.      * @since 4.7
  630.      */
  631.     public static final String LOCK_SUFFIX = ".lock"; //$NON-NLS-1$

  632.     private Constants() {
  633.         // Hide the default constructor
  634.     }
  635. }