You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Constants.java 21KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731
  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. /** Info refs folder */
  216. public static final String INFO_REFS = "info/refs";
  217. /**
  218. * Info alternates file (goes under OBJECTS)
  219. * @since 5.5
  220. */
  221. public static final String INFO_ALTERNATES = "info/alternates";
  222. /**
  223. * HTTP alternates file (goes under OBJECTS)
  224. * @since 5.5
  225. */
  226. public static final String INFO_HTTP_ALTERNATES = "info/http-alternates";
  227. /** Packed refs file */
  228. public static final String PACKED_REFS = "packed-refs";
  229. /**
  230. * Excludes-file
  231. *
  232. * @since 3.0
  233. */
  234. public static final String INFO_EXCLUDE = "info/exclude";
  235. /**
  236. * Attributes-override-file
  237. *
  238. * @since 4.2
  239. */
  240. public static final String INFO_ATTRIBUTES = "info/attributes";
  241. /**
  242. * The system property that contains the system user name
  243. *
  244. * @since 3.6
  245. */
  246. public static final String OS_USER_DIR = "user.dir";
  247. /** The system property that contains the system user name */
  248. public static final String OS_USER_NAME_KEY = "user.name";
  249. /** The environment variable that contains the author's name */
  250. public static final String GIT_AUTHOR_NAME_KEY = "GIT_AUTHOR_NAME";
  251. /** The environment variable that contains the author's email */
  252. public static final String GIT_AUTHOR_EMAIL_KEY = "GIT_AUTHOR_EMAIL";
  253. /** The environment variable that contains the commiter's name */
  254. public static final String GIT_COMMITTER_NAME_KEY = "GIT_COMMITTER_NAME";
  255. /** The environment variable that contains the commiter's email */
  256. public static final String GIT_COMMITTER_EMAIL_KEY = "GIT_COMMITTER_EMAIL";
  257. /**
  258. * The environment variable that blocks use of the system config file
  259. *
  260. * @since 3.3
  261. */
  262. public static final String GIT_CONFIG_NOSYSTEM_KEY = "GIT_CONFIG_NOSYSTEM";
  263. /**
  264. * The key of the XDG_CONFIG_HOME directory defined in the XDG base
  265. * directory specification, see
  266. * {@link "https://wiki.archlinux.org/index.php/XDG_Base_Directory"}
  267. *
  268. * @since 5.5.2
  269. */
  270. public static final String XDG_CONFIG_HOME = "XDG_CONFIG_HOME";
  271. /**
  272. * The environment variable that limits how close to the root of the file
  273. * systems JGit will traverse when looking for a repository root.
  274. */
  275. public static final String GIT_CEILING_DIRECTORIES_KEY = "GIT_CEILING_DIRECTORIES";
  276. /**
  277. * The environment variable that tells us which directory is the ".git"
  278. * directory
  279. */
  280. public static final String GIT_DIR_KEY = "GIT_DIR";
  281. /**
  282. * The environment variable that tells us which directory is the working
  283. * directory.
  284. */
  285. public static final String GIT_WORK_TREE_KEY = "GIT_WORK_TREE";
  286. /**
  287. * The environment variable that tells us which file holds the Git index.
  288. */
  289. public static final String GIT_INDEX_FILE_KEY = "GIT_INDEX_FILE";
  290. /**
  291. * The environment variable that tells us where objects are stored
  292. */
  293. public static final String GIT_OBJECT_DIRECTORY_KEY = "GIT_OBJECT_DIRECTORY";
  294. /**
  295. * The environment variable that tells us where to look for objects, besides
  296. * the default objects directory.
  297. */
  298. public static final String GIT_ALTERNATE_OBJECT_DIRECTORIES_KEY = "GIT_ALTERNATE_OBJECT_DIRECTORIES";
  299. /** Default value for the user name if no other information is available */
  300. public static final String UNKNOWN_USER_DEFAULT = "unknown-user";
  301. /** Beginning of the common "Signed-off-by: " commit message line */
  302. public static final String SIGNED_OFF_BY_TAG = "Signed-off-by: ";
  303. /** A gitignore file name */
  304. public static final String GITIGNORE_FILENAME = ".gitignore";
  305. /** Default remote name used by clone, push and fetch operations */
  306. public static final String DEFAULT_REMOTE_NAME = "origin";
  307. /** Default name for the Git repository directory */
  308. public static final String DOT_GIT = ".git";
  309. /** Default name for the Git repository configuration */
  310. public static final String CONFIG = "config";
  311. /** A bare repository typically ends with this string */
  312. public static final String DOT_GIT_EXT = ".git";
  313. /**
  314. * Name of the attributes file
  315. *
  316. * @since 3.7
  317. */
  318. public static final String DOT_GIT_ATTRIBUTES = ".gitattributes";
  319. /**
  320. * Key for filters in .gitattributes
  321. *
  322. * @since 4.2
  323. */
  324. public static final String ATTR_FILTER = "filter";
  325. /**
  326. * clean command name, used to call filter driver
  327. *
  328. * @since 4.2
  329. */
  330. public static final String ATTR_FILTER_TYPE_CLEAN = "clean";
  331. /**
  332. * smudge command name, used to call filter driver
  333. *
  334. * @since 4.2
  335. */
  336. public static final String ATTR_FILTER_TYPE_SMUDGE = "smudge";
  337. /**
  338. * Builtin filter commands start with this prefix
  339. *
  340. * @since 4.6
  341. */
  342. public static final String BUILTIN_FILTER_PREFIX = "jgit://builtin/";
  343. /** Name of the ignore file */
  344. public static final String DOT_GIT_IGNORE = ".gitignore";
  345. /** Name of the submodules file */
  346. public static final String DOT_GIT_MODULES = ".gitmodules";
  347. /** Name of the .git/shallow file */
  348. public static final String SHALLOW = "shallow";
  349. /**
  350. * Prefix of the first line in a ".git" file
  351. *
  352. * @since 3.6
  353. */
  354. public static final String GITDIR = "gitdir: ";
  355. /**
  356. * Name of the folder (inside gitDir) where submodules are stored
  357. *
  358. * @since 3.6
  359. */
  360. public static final String MODULES = "modules";
  361. /**
  362. * Name of the folder (inside gitDir) where the hooks are stored.
  363. *
  364. * @since 3.7
  365. */
  366. public static final String HOOKS = "hooks";
  367. /**
  368. * Merge attribute.
  369. *
  370. * @since 4.9
  371. */
  372. public static final String ATTR_MERGE = "merge"; //$NON-NLS-1$
  373. /**
  374. * Diff attribute.
  375. *
  376. * @since 4.11
  377. */
  378. public static final String ATTR_DIFF = "diff"; //$NON-NLS-1$
  379. /**
  380. * Binary value for custom merger.
  381. *
  382. * @since 4.9
  383. */
  384. public static final String ATTR_BUILTIN_BINARY_MERGER = "binary"; //$NON-NLS-1$
  385. /**
  386. * Create a new digest function for objects.
  387. *
  388. * @return a new digest object.
  389. * @throws java.lang.RuntimeException
  390. * this Java virtual machine does not support the required hash
  391. * function. Very unlikely given that JGit uses a hash function
  392. * that is in the Java reference specification.
  393. */
  394. public static MessageDigest newMessageDigest() {
  395. try {
  396. return MessageDigest.getInstance(HASH_FUNCTION);
  397. } catch (NoSuchAlgorithmException nsae) {
  398. throw new RuntimeException(MessageFormat.format(
  399. JGitText.get().requiredHashFunctionNotAvailable, HASH_FUNCTION), nsae);
  400. }
  401. }
  402. /**
  403. * Convert an OBJ_* type constant to a TYPE_* type constant.
  404. *
  405. * @param typeCode the type code, from a pack representation.
  406. * @return the canonical string name of this type.
  407. */
  408. public static String typeString(int typeCode) {
  409. switch (typeCode) {
  410. case OBJ_COMMIT:
  411. return TYPE_COMMIT;
  412. case OBJ_TREE:
  413. return TYPE_TREE;
  414. case OBJ_BLOB:
  415. return TYPE_BLOB;
  416. case OBJ_TAG:
  417. return TYPE_TAG;
  418. default:
  419. throw new IllegalArgumentException(MessageFormat.format(
  420. JGitText.get().badObjectType, Integer.valueOf(typeCode)));
  421. }
  422. }
  423. /**
  424. * Convert an OBJ_* type constant to an ASCII encoded string constant.
  425. * <p>
  426. * The ASCII encoded string is often the canonical representation of
  427. * the type within a loose object header, or within a tag header.
  428. *
  429. * @param typeCode the type code, from a pack representation.
  430. * @return the canonical ASCII encoded name of this type.
  431. */
  432. public static byte[] encodedTypeString(int typeCode) {
  433. switch (typeCode) {
  434. case OBJ_COMMIT:
  435. return ENCODED_TYPE_COMMIT;
  436. case OBJ_TREE:
  437. return ENCODED_TYPE_TREE;
  438. case OBJ_BLOB:
  439. return ENCODED_TYPE_BLOB;
  440. case OBJ_TAG:
  441. return ENCODED_TYPE_TAG;
  442. default:
  443. throw new IllegalArgumentException(MessageFormat.format(
  444. JGitText.get().badObjectType, Integer.valueOf(typeCode)));
  445. }
  446. }
  447. /**
  448. * Parse an encoded type string into a type constant.
  449. *
  450. * @param id
  451. * object id this type string came from; may be null if that is
  452. * not known at the time the parse is occurring.
  453. * @param typeString
  454. * string version of the type code.
  455. * @param endMark
  456. * character immediately following the type string. Usually ' '
  457. * (space) or '\n' (line feed).
  458. * @param offset
  459. * position within <code>typeString</code> where the parse
  460. * should start. Updated with the new position (just past
  461. * <code>endMark</code> when the parse is successful.
  462. * @return a type code constant (one of {@link #OBJ_BLOB},
  463. * {@link #OBJ_COMMIT}, {@link #OBJ_TAG}, {@link #OBJ_TREE}.
  464. * @throws org.eclipse.jgit.errors.CorruptObjectException
  465. * there is no valid type identified by <code>typeString</code>.
  466. */
  467. public static int decodeTypeString(final AnyObjectId id,
  468. final byte[] typeString, final byte endMark,
  469. final MutableInteger offset) throws CorruptObjectException {
  470. try {
  471. int position = offset.value;
  472. switch (typeString[position]) {
  473. case 'b':
  474. if (typeString[position + 1] != 'l'
  475. || typeString[position + 2] != 'o'
  476. || typeString[position + 3] != 'b'
  477. || typeString[position + 4] != endMark)
  478. throw new CorruptObjectException(id, JGitText.get().corruptObjectInvalidType);
  479. offset.value = position + 5;
  480. return Constants.OBJ_BLOB;
  481. case 'c':
  482. if (typeString[position + 1] != 'o'
  483. || typeString[position + 2] != 'm'
  484. || typeString[position + 3] != 'm'
  485. || typeString[position + 4] != 'i'
  486. || typeString[position + 5] != 't'
  487. || typeString[position + 6] != endMark)
  488. throw new CorruptObjectException(id, JGitText.get().corruptObjectInvalidType);
  489. offset.value = position + 7;
  490. return Constants.OBJ_COMMIT;
  491. case 't':
  492. switch (typeString[position + 1]) {
  493. case 'a':
  494. if (typeString[position + 2] != 'g'
  495. || typeString[position + 3] != endMark)
  496. throw new CorruptObjectException(id, JGitText.get().corruptObjectInvalidType);
  497. offset.value = position + 4;
  498. return Constants.OBJ_TAG;
  499. case 'r':
  500. if (typeString[position + 2] != 'e'
  501. || typeString[position + 3] != 'e'
  502. || typeString[position + 4] != endMark)
  503. throw new CorruptObjectException(id, JGitText.get().corruptObjectInvalidType);
  504. offset.value = position + 5;
  505. return Constants.OBJ_TREE;
  506. default:
  507. throw new CorruptObjectException(id, JGitText.get().corruptObjectInvalidType);
  508. }
  509. default:
  510. throw new CorruptObjectException(id, JGitText.get().corruptObjectInvalidType);
  511. }
  512. } catch (ArrayIndexOutOfBoundsException bad) {
  513. CorruptObjectException coe = new CorruptObjectException(id,
  514. JGitText.get().corruptObjectInvalidType);
  515. coe.initCause(bad);
  516. throw coe;
  517. }
  518. }
  519. /**
  520. * Convert an integer into its decimal representation.
  521. *
  522. * @param s
  523. * the integer to convert.
  524. * @return a decimal representation of the input integer. The returned array
  525. * is the smallest array that will hold the value.
  526. */
  527. public static byte[] encodeASCII(long s) {
  528. return encodeASCII(Long.toString(s));
  529. }
  530. /**
  531. * Convert a string to US-ASCII encoding.
  532. *
  533. * @param s
  534. * the string to convert. Must not contain any characters over
  535. * 127 (outside of 7-bit ASCII).
  536. * @return a byte array of the same length as the input string, holding the
  537. * same characters, in the same order.
  538. * @throws java.lang.IllegalArgumentException
  539. * the input string contains one or more characters outside of
  540. * the 7-bit ASCII character space.
  541. */
  542. public static byte[] encodeASCII(String s) {
  543. final byte[] r = new byte[s.length()];
  544. for (int k = r.length - 1; k >= 0; k--) {
  545. final char c = s.charAt(k);
  546. if (c > 127)
  547. throw new IllegalArgumentException(MessageFormat.format(JGitText.get().notASCIIString, s));
  548. r[k] = (byte) c;
  549. }
  550. return r;
  551. }
  552. /**
  553. * Convert a string to a byte array in the standard character encoding.
  554. *
  555. * @param str
  556. * the string to convert. May contain any Unicode characters.
  557. * @return a byte array representing the requested string, encoded using the
  558. * default character encoding (UTF-8).
  559. * @see #CHARACTER_ENCODING
  560. */
  561. public static byte[] encode(String str) {
  562. final ByteBuffer bb = UTF_8.encode(str);
  563. final int len = bb.limit();
  564. if (bb.hasArray() && bb.arrayOffset() == 0) {
  565. final byte[] arr = bb.array();
  566. if (arr.length == len)
  567. return arr;
  568. }
  569. final byte[] arr = new byte[len];
  570. bb.get(arr);
  571. return arr;
  572. }
  573. static {
  574. if (OBJECT_ID_LENGTH != newMessageDigest().getDigestLength())
  575. throw new LinkageError(JGitText.get().incorrectOBJECT_ID_LENGTH);
  576. CHARSET = UTF_8;
  577. CHARACTER_ENCODING = UTF_8.name();
  578. }
  579. /** name of the file containing the commit msg for a merge commit */
  580. public static final String MERGE_MSG = "MERGE_MSG";
  581. /** name of the file containing the IDs of the parents of a merge commit */
  582. public static final String MERGE_HEAD = "MERGE_HEAD";
  583. /** name of the file containing the ID of a cherry pick commit in case of conflicts */
  584. public static final String CHERRY_PICK_HEAD = "CHERRY_PICK_HEAD";
  585. /** name of the file containing the commit msg for a squash commit */
  586. public static final String SQUASH_MSG = "SQUASH_MSG";
  587. /** name of the file containing the ID of a revert commit in case of conflicts */
  588. public static final String REVERT_HEAD = "REVERT_HEAD";
  589. /**
  590. * name of the ref ORIG_HEAD used by certain commands to store the original
  591. * value of HEAD
  592. */
  593. public static final String ORIG_HEAD = "ORIG_HEAD";
  594. /**
  595. * Name of the file in which git commands and hooks store and read the
  596. * message prepared for the upcoming commit.
  597. *
  598. * @since 4.0
  599. */
  600. public static final String COMMIT_EDITMSG = "COMMIT_EDITMSG";
  601. /**
  602. * Well-known object ID for the empty blob.
  603. *
  604. * @since 0.9.1
  605. */
  606. public static final ObjectId EMPTY_BLOB_ID = ObjectId
  607. .fromString("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391");
  608. /**
  609. * Well-known object ID for the empty tree.
  610. *
  611. * @since 5.1
  612. */
  613. public static final ObjectId EMPTY_TREE_ID = ObjectId
  614. .fromString("4b825dc642cb6eb9a060e54bf8d69288fbee4904");
  615. /**
  616. * Suffix of lock file name
  617. *
  618. * @since 4.7
  619. */
  620. public static final String LOCK_SUFFIX = ".lock"; //$NON-NLS-1$
  621. private Constants() {
  622. // Hide the default constructor
  623. }
  624. }