View Javadoc
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  
13  package org.eclipse.jgit.lib;
14  
15  import static java.nio.charset.StandardCharsets.UTF_8;
16  
17  import java.nio.ByteBuffer;
18  import java.nio.charset.Charset;
19  import java.security.MessageDigest;
20  import java.security.NoSuchAlgorithmException;
21  import java.text.MessageFormat;
22  
23  import org.eclipse.jgit.errors.CorruptObjectException;
24  import org.eclipse.jgit.internal.JGitText;
25  import org.eclipse.jgit.util.MutableInteger;
26  
27  /**
28   * Misc. constants and helpers used throughout JGit.
29   */
30  @SuppressWarnings("nls")
31  public final class Constants {
32  	/** Hash function used natively by Git for all objects. */
33  	private static final String HASH_FUNCTION = "SHA-1";
34  
35  	/**
36  	 * A Git object hash is 160 bits, i.e. 20 bytes.
37  	 * <p>
38  	 * Changing this assumption is not going to be as easy as changing this
39  	 * declaration.
40  	 */
41  	public static final int OBJECT_ID_LENGTH = 20;
42  
43  	/**
44  	 * A Git object can be expressed as a 40 character string of hexadecimal
45  	 * digits.
46  	 *
47  	 * @see #OBJECT_ID_LENGTH
48  	 */
49  	public static final int OBJECT_ID_STRING_LENGTH = OBJECT_ID_LENGTH * 2;
50  
51  	/**
52  	 * The historic length of an abbreviated Git object hash string. Git 2.11
53  	 * changed this static number to a dynamically calculated one that scales
54  	 * as the repository grows.
55  	 *
56  	 * @since 6.1
57  	 */
58  	public static final int OBJECT_ID_ABBREV_STRING_LENGTH = 7;
59  
60  	/** Special name for the "HEAD" symbolic-ref. */
61  	public static final String HEAD = "HEAD";
62  
63  	/** Special name for the "FETCH_HEAD" symbolic-ref. */
64  	public static final String FETCH_HEAD = "FETCH_HEAD";
65  
66  	/**
67  	 * Text string that identifies an object as a commit.
68  	 * <p>
69  	 * Commits connect trees into a string of project histories, where each
70  	 * commit is an assertion that the best way to continue is to use this other
71  	 * tree (set of files).
72  	 */
73  	public static final String TYPE_COMMIT = "commit";
74  
75  	/**
76  	 * Text string that identifies an object as a blob.
77  	 * <p>
78  	 * Blobs store whole file revisions. They are used for any user file, as
79  	 * well as for symlinks. Blobs form the bulk of any project's storage space.
80  	 */
81  	public static final String TYPE_BLOB = "blob";
82  
83  	/**
84  	 * Text string that identifies an object as a tree.
85  	 * <p>
86  	 * Trees attach object ids (hashes) to names and file modes. The normal use
87  	 * for a tree is to store a version of a directory and its contents.
88  	 */
89  	public static final String TYPE_TREE = "tree";
90  
91  	/**
92  	 * Text string that identifies an object as an annotated tag.
93  	 * <p>
94  	 * Annotated tags store a pointer to any other object, and an additional
95  	 * message. It is most commonly used to record a stable release of the
96  	 * project.
97  	 */
98  	public static final String TYPE_TAG = "tag";
99  
100 	private static final byte[] ENCODED_TYPE_COMMIT = encodeASCII(TYPE_COMMIT);
101 
102 	private static final byte[] ENCODED_TYPE_BLOB = encodeASCII(TYPE_BLOB);
103 
104 	private static final byte[] ENCODED_TYPE_TREE = encodeASCII(TYPE_TREE);
105 
106 	private static final byte[] ENCODED_TYPE_TAG = encodeASCII(TYPE_TAG);
107 
108 	/** An unknown or invalid object type code. */
109 	public static final int OBJ_BAD = -1;
110 
111 	/**
112 	 * In-pack object type: extended types.
113 	 * <p>
114 	 * This header code is reserved for future expansion. It is currently
115 	 * undefined/unsupported.
116 	 */
117 	public static final int OBJ_EXT = 0;
118 
119 	/**
120 	 * In-pack object type: commit.
121 	 * <p>
122 	 * Indicates the associated object is a commit.
123 	 * <p>
124 	 * <b>This constant is fixed and is defined by the Git packfile format.</b>
125 	 *
126 	 * @see #TYPE_COMMIT
127 	 */
128 	public static final int OBJ_COMMIT = 1;
129 
130 	/**
131 	 * In-pack object type: tree.
132 	 * <p>
133 	 * Indicates the associated object is a tree.
134 	 * <p>
135 	 * <b>This constant is fixed and is defined by the Git packfile format.</b>
136 	 *
137 	 * @see #TYPE_BLOB
138 	 */
139 	public static final int OBJ_TREE = 2;
140 
141 	/**
142 	 * In-pack object type: blob.
143 	 * <p>
144 	 * Indicates the associated object is a blob.
145 	 * <p>
146 	 * <b>This constant is fixed and is defined by the Git packfile format.</b>
147 	 *
148 	 * @see #TYPE_BLOB
149 	 */
150 	public static final int OBJ_BLOB = 3;
151 
152 	/**
153 	 * In-pack object type: annotated tag.
154 	 * <p>
155 	 * Indicates the associated object is an annotated tag.
156 	 * <p>
157 	 * <b>This constant is fixed and is defined by the Git packfile format.</b>
158 	 *
159 	 * @see #TYPE_TAG
160 	 */
161 	public static final int OBJ_TAG = 4;
162 
163 	/** In-pack object type: reserved for future use. */
164 	public static final int OBJ_TYPE_5 = 5;
165 
166 	/**
167 	 * In-pack object type: offset delta
168 	 * <p>
169 	 * Objects stored with this type actually have a different type which must
170 	 * be obtained from their delta base object. Delta objects store only the
171 	 * changes needed to apply to the base object in order to recover the
172 	 * original object.
173 	 * <p>
174 	 * An offset delta uses a negative offset from the start of this object to
175 	 * refer to its delta base. The base object must exist in this packfile
176 	 * (even in the case of a thin pack).
177 	 * <p>
178 	 * <b>This constant is fixed and is defined by the Git packfile format.</b>
179 	 */
180 	public static final int OBJ_OFS_DELTA = 6;
181 
182 	/**
183 	 * In-pack object type: reference delta
184 	 * <p>
185 	 * Objects stored with this type actually have a different type which must
186 	 * be obtained from their delta base object. Delta objects store only the
187 	 * changes needed to apply to the base object in order to recover the
188 	 * original object.
189 	 * <p>
190 	 * A reference delta uses a full object id (hash) to reference the delta
191 	 * base. The base object is allowed to be omitted from the packfile, but
192 	 * only in the case of a thin pack being transferred over the network.
193 	 * <p>
194 	 * <b>This constant is fixed and is defined by the Git packfile format.</b>
195 	 */
196 	public static final int OBJ_REF_DELTA = 7;
197 
198 	/**
199 	 * Pack file signature that occurs at file header - identifies file as Git
200 	 * packfile formatted.
201 	 * <p>
202 	 * <b>This constant is fixed and is defined by the Git packfile format.</b>
203 	 */
204 	public static final byte[] PACK_SIGNATURE = { 'P', 'A', 'C', 'K' };
205 
206 	/**
207 	 * Native character encoding for commit messages, file names...
208 	 *
209 	 * @deprecated Use {@link java.nio.charset.StandardCharsets#UTF_8} directly
210 	 *             instead.
211 	 */
212 	@Deprecated
213 	public static final Charset CHARSET;
214 
215 	/**
216 	 * Native character encoding for commit messages, file names...
217 	 *
218 	 * @deprecated Use {@link java.nio.charset.StandardCharsets#UTF_8} directly
219 	 *             instead.
220 	 */
221 	@Deprecated
222 	public static final String CHARACTER_ENCODING;
223 
224 	/** Default main branch name */
225 	public static final String MASTER = "master";
226 
227 	/** Default stash branch name */
228 	public static final String STASH = "stash";
229 
230 	/** Prefix for branch refs */
231 	public static final String R_HEADS = "refs/heads/";
232 
233 	/** Prefix for remotes refs */
234 	public static final String R_REMOTES = "refs/remotes/";
235 
236 	/** Prefix for tag refs */
237 	public static final String R_TAGS = "refs/tags/";
238 
239 	/** Prefix for notes refs */
240 	public static final String R_NOTES = "refs/notes/";
241 
242 	/** Standard notes ref */
243 	public static final String R_NOTES_COMMITS = R_NOTES + "commits";
244 
245 	/** Prefix for any ref */
246 	public static final String R_REFS = "refs/";
247 
248 	/** Standard stash ref */
249 	public static final String R_STASH = R_REFS + STASH;
250 
251 	/** Logs folder name */
252 	public static final String LOGS = "logs";
253 
254 	/**
255 	 * Objects folder name
256 	 * @since 5.5
257 	 */
258 	public static final String OBJECTS = "objects";
259 
260 	/**
261 	 * Reftable folder name
262 	 * @since 5.6
263 	 */
264 	public static final String REFTABLE = "reftable";
265 
266 	/**
267 	 * Reftable table list name.
268 	 * @since 5.6.2
269 	 */
270 	public static final String TABLES_LIST = "tables.list";
271 
272 	/** Info refs folder */
273 	public static final String INFO_REFS = "info/refs";
274 
275 	/**
276 	 * Info alternates file (goes under OBJECTS)
277 	 * @since 5.5
278 	 */
279 	public static final String INFO_ALTERNATES = "info/alternates";
280 
281 	/**
282 	 * HTTP alternates file (goes under OBJECTS)
283 	 * @since 5.5
284 	 */
285 	public static final String INFO_HTTP_ALTERNATES = "info/http-alternates";
286 
287 	/** Packed refs file */
288 	public static final String PACKED_REFS = "packed-refs";
289 
290 	/**
291 	 * Excludes-file
292 	 *
293 	 * @since 3.0
294 	 */
295 	public static final String INFO_EXCLUDE = "info/exclude";
296 
297 	/**
298 	 * Attributes-override-file
299 	 *
300 	 * @since 4.2
301 	 */
302 	public static final String INFO_ATTRIBUTES = "info/attributes";
303 
304 	/**
305 	 * The system property that contains the system user name
306 	 *
307 	 * @since 3.6
308 	 */
309 	public static final String OS_USER_DIR = "user.dir";
310 
311 	/** The system property that contains the system user name */
312 	public static final String OS_USER_NAME_KEY = "user.name";
313 
314 	/** The environment variable that contains the author's name */
315 	public static final String GIT_AUTHOR_NAME_KEY = "GIT_AUTHOR_NAME";
316 
317 	/** The environment variable that contains the author's email */
318 	public static final String GIT_AUTHOR_EMAIL_KEY = "GIT_AUTHOR_EMAIL";
319 
320 	/** The environment variable that contains the commiter's name */
321 	public static final String GIT_COMMITTER_NAME_KEY = "GIT_COMMITTER_NAME";
322 
323 	/** The environment variable that contains the commiter's email */
324 	public static final String GIT_COMMITTER_EMAIL_KEY = "GIT_COMMITTER_EMAIL";
325 
326 	/**
327 	 * The environment variable that blocks use of the system config file
328 	 *
329 	 * @since 3.3
330 	 */
331 	public static final String GIT_CONFIG_NOSYSTEM_KEY = "GIT_CONFIG_NOSYSTEM";
332 
333 	/**
334 	 * The key of the XDG_CONFIG_HOME directory defined in the XDG base
335 	 * directory specification, see
336 	 * {@link "https://wiki.archlinux.org/index.php/XDG_Base_Directory"}
337 	 *
338 	 * @since 5.5.2
339 	 */
340 	public static final String XDG_CONFIG_HOME = "XDG_CONFIG_HOME";
341 
342 	/**
343 	 * The environment variable that limits how close to the root of the file
344 	 * systems JGit will traverse when looking for a repository root.
345 	 */
346 	public static final String GIT_CEILING_DIRECTORIES_KEY = "GIT_CEILING_DIRECTORIES";
347 
348 	/**
349 	 * The environment variable that tells us which directory is the ".git"
350 	 * directory
351 	 */
352 	public static final String GIT_DIR_KEY = "GIT_DIR";
353 
354 	/**
355 	 * The environment variable that tells us which directory is the working
356 	 * directory.
357 	 */
358 	public static final String GIT_WORK_TREE_KEY = "GIT_WORK_TREE";
359 
360 	/**
361 	 * The environment variable that tells us which file holds the Git index.
362 	 */
363 	public static final String GIT_INDEX_FILE_KEY = "GIT_INDEX_FILE";
364 
365 	/**
366 	 * The environment variable that tells us where objects are stored
367 	 */
368 	public static final String GIT_OBJECT_DIRECTORY_KEY = "GIT_OBJECT_DIRECTORY";
369 
370 	/**
371 	 * The environment variable that tells us where to look for objects, besides
372 	 * the default objects directory.
373 	 */
374 	public static final String GIT_ALTERNATE_OBJECT_DIRECTORIES_KEY = "GIT_ALTERNATE_OBJECT_DIRECTORIES";
375 
376 	/** Default value for the user name if no other information is available */
377 	public static final String UNKNOWN_USER_DEFAULT = "unknown-user";
378 
379 	/** Beginning of the common "Signed-off-by: " commit message line */
380 	public static final String SIGNED_OFF_BY_TAG = "Signed-off-by: ";
381 
382 	/** A gitignore file name */
383 	public static final String GITIGNORE_FILENAME = ".gitignore";
384 
385 	/** Default remote name used by clone, push and fetch operations */
386 	public static final String DEFAULT_REMOTE_NAME = "origin";
387 
388 	/** Default name for the Git repository directory */
389 	public static final String DOT_GIT = ".git";
390 
391 	/** Default name for the Git repository configuration */
392 	public static final String CONFIG = "config";
393 
394 	/** A bare repository typically ends with this string */
395 	public static final String DOT_GIT_EXT = ".git";
396 
397 	/**
398 	 * The default extension for local bundle files
399 	 *
400 	 * @since 5.8
401 	 */
402 	public static final String DOT_BUNDLE_EXT = ".bundle";
403 
404 	/**
405 	 * Name of the attributes file
406 	 *
407 	 * @since 3.7
408 	 */
409 	public static final String DOT_GIT_ATTRIBUTES = ".gitattributes";
410 
411 	/**
412 	 * Key for filters in .gitattributes
413 	 *
414 	 * @since 4.2
415 	 */
416 	public static final String ATTR_FILTER = "filter";
417 
418 	/**
419 	 * clean command name, used to call filter driver
420 	 *
421 	 * @since 4.2
422 	 */
423 	public static final String ATTR_FILTER_TYPE_CLEAN = "clean";
424 
425 	/**
426 	 * smudge command name, used to call filter driver
427 	 *
428 	 * @since 4.2
429 	 */
430 	public static final String ATTR_FILTER_TYPE_SMUDGE = "smudge";
431 
432 	/**
433 	 * Builtin filter commands start with this prefix
434 	 *
435 	 * @since 4.6
436 	 */
437 	public static final String BUILTIN_FILTER_PREFIX = "jgit://builtin/";
438 
439 	/** Name of the ignore file */
440 	public static final String DOT_GIT_IGNORE = ".gitignore";
441 
442 	/** Name of the submodules file */
443 	public static final String DOT_GIT_MODULES = ".gitmodules";
444 
445 	/** Name of the .git/shallow file */
446 	public static final String SHALLOW = "shallow";
447 
448 	/**
449 	 * Prefix of the first line in a ".git" file
450 	 *
451 	 * @since 3.6
452 	 */
453 	public static final String GITDIR = "gitdir: ";
454 
455 	/**
456 	 * Name of the folder (inside gitDir) where submodules are stored
457 	 *
458 	 * @since 3.6
459 	 */
460 	public static final String MODULES = "modules";
461 
462 	/**
463 	 * Name of the folder (inside gitDir) where the hooks are stored.
464 	 *
465 	 * @since 3.7
466 	 */
467 	public static final String HOOKS = "hooks";
468 
469 	/**
470 	 * Merge attribute.
471 	 *
472 	 * @since 4.9
473 	 */
474 	public static final String ATTR_MERGE = "merge"; //$NON-NLS-1$
475 
476 	/**
477 	 * Diff attribute.
478 	 *
479 	 * @since 4.11
480 	 */
481 	public static final String ATTR_DIFF = "diff"; //$NON-NLS-1$
482 
483 	/**
484 	 * Binary value for custom merger.
485 	 *
486 	 * @since 4.9
487 	 */
488 	public static final String ATTR_BUILTIN_BINARY_MERGER = "binary"; //$NON-NLS-1$
489 
490 	/**
491 	 * Create a new digest function for objects.
492 	 *
493 	 * @return a new digest object.
494 	 * @throws java.lang.RuntimeException
495 	 *             this Java virtual machine does not support the required hash
496 	 *             function. Very unlikely given that JGit uses a hash function
497 	 *             that is in the Java reference specification.
498 	 */
499 	public static MessageDigest newMessageDigest() {
500 		try {
501 			return MessageDigest.getInstance(HASH_FUNCTION);
502 		} catch (NoSuchAlgorithmException nsae) {
503 			throw new RuntimeException(MessageFormat.format(
504 					JGitText.get().requiredHashFunctionNotAvailable, HASH_FUNCTION), nsae);
505 		}
506 	}
507 
508 	/**
509 	 * Convert an OBJ_* type constant to a TYPE_* type constant.
510 	 *
511 	 * @param typeCode the type code, from a pack representation.
512 	 * @return the canonical string name of this type.
513 	 */
514 	public static String typeString(int typeCode) {
515 		switch (typeCode) {
516 		case OBJ_COMMIT:
517 			return TYPE_COMMIT;
518 		case OBJ_TREE:
519 			return TYPE_TREE;
520 		case OBJ_BLOB:
521 			return TYPE_BLOB;
522 		case OBJ_TAG:
523 			return TYPE_TAG;
524 		default:
525 			throw new IllegalArgumentException(MessageFormat.format(
526 					JGitText.get().badObjectType, Integer.valueOf(typeCode)));
527 		}
528 	}
529 
530 	/**
531 	 * Convert an OBJ_* type constant to an ASCII encoded string constant.
532 	 * <p>
533 	 * The ASCII encoded string is often the canonical representation of
534 	 * the type within a loose object header, or within a tag header.
535 	 *
536 	 * @param typeCode the type code, from a pack representation.
537 	 * @return the canonical ASCII encoded name of this type.
538 	 */
539 	public static byte[] encodedTypeString(int typeCode) {
540 		switch (typeCode) {
541 		case OBJ_COMMIT:
542 			return ENCODED_TYPE_COMMIT;
543 		case OBJ_TREE:
544 			return ENCODED_TYPE_TREE;
545 		case OBJ_BLOB:
546 			return ENCODED_TYPE_BLOB;
547 		case OBJ_TAG:
548 			return ENCODED_TYPE_TAG;
549 		default:
550 			throw new IllegalArgumentException(MessageFormat.format(
551 					JGitText.get().badObjectType, Integer.valueOf(typeCode)));
552 		}
553 	}
554 
555 	/**
556 	 * Parse an encoded type string into a type constant.
557 	 *
558 	 * @param id
559 	 *            object id this type string came from; may be null if that is
560 	 *            not known at the time the parse is occurring.
561 	 * @param typeString
562 	 *            string version of the type code.
563 	 * @param endMark
564 	 *            character immediately following the type string. Usually ' '
565 	 *            (space) or '\n' (line feed).
566 	 * @param offset
567 	 *            position within <code>typeString</code> where the parse
568 	 *            should start. Updated with the new position (just past
569 	 *            <code>endMark</code> when the parse is successful.
570 	 * @return a type code constant (one of {@link #OBJ_BLOB},
571 	 *         {@link #OBJ_COMMIT}, {@link #OBJ_TAG}, {@link #OBJ_TREE}.
572 	 * @throws org.eclipse.jgit.errors.CorruptObjectException
573 	 *             there is no valid type identified by <code>typeString</code>.
574 	 */
575 	public static int decodeTypeString(final AnyObjectId id,
576 			final byte[] typeString, final byte endMark,
577 			final MutableInteger offset) throws CorruptObjectException {
578 		try {
579 			int position = offset.value;
580 			switch (typeString[position]) {
581 			case 'b':
582 				if (typeString[position + 1] != 'l'
583 						|| typeString[position + 2] != 'o'
584 						|| typeString[position + 3] != 'b'
585 						|| typeString[position + 4] != endMark)
586 					throw new CorruptObjectException(id, JGitText.get().corruptObjectInvalidType);
587 				offset.value = position + 5;
588 				return Constants.OBJ_BLOB;
589 
590 			case 'c':
591 				if (typeString[position + 1] != 'o'
592 						|| typeString[position + 2] != 'm'
593 						|| typeString[position + 3] != 'm'
594 						|| typeString[position + 4] != 'i'
595 						|| typeString[position + 5] != 't'
596 						|| typeString[position + 6] != endMark)
597 					throw new CorruptObjectException(id, JGitText.get().corruptObjectInvalidType);
598 				offset.value = position + 7;
599 				return Constants.OBJ_COMMIT;
600 
601 			case 't':
602 				switch (typeString[position + 1]) {
603 				case 'a':
604 					if (typeString[position + 2] != 'g'
605 							|| typeString[position + 3] != endMark)
606 						throw new CorruptObjectException(id, JGitText.get().corruptObjectInvalidType);
607 					offset.value = position + 4;
608 					return Constants.OBJ_TAG;
609 
610 				case 'r':
611 					if (typeString[position + 2] != 'e'
612 							|| typeString[position + 3] != 'e'
613 							|| typeString[position + 4] != endMark)
614 						throw new CorruptObjectException(id, JGitText.get().corruptObjectInvalidType);
615 					offset.value = position + 5;
616 					return Constants.OBJ_TREE;
617 
618 				default:
619 					throw new CorruptObjectException(id, JGitText.get().corruptObjectInvalidType);
620 				}
621 
622 			default:
623 				throw new CorruptObjectException(id, JGitText.get().corruptObjectInvalidType);
624 			}
625 		} catch (ArrayIndexOutOfBoundsException bad) {
626 			CorruptObjectException coe = new CorruptObjectException(id,
627 					JGitText.get().corruptObjectInvalidType);
628 			coe.initCause(bad);
629 			throw coe;
630 		}
631 	}
632 
633 	/**
634 	 * Convert an integer into its decimal representation.
635 	 *
636 	 * @param s
637 	 *            the integer to convert.
638 	 * @return a decimal representation of the input integer. The returned array
639 	 *         is the smallest array that will hold the value.
640 	 */
641 	public static byte[] encodeASCII(long s) {
642 		return encodeASCII(Long.toString(s));
643 	}
644 
645 	/**
646 	 * Convert a string to US-ASCII encoding.
647 	 *
648 	 * @param s
649 	 *            the string to convert. Must not contain any characters over
650 	 *            127 (outside of 7-bit ASCII).
651 	 * @return a byte array of the same length as the input string, holding the
652 	 *         same characters, in the same order.
653 	 * @throws java.lang.IllegalArgumentException
654 	 *             the input string contains one or more characters outside of
655 	 *             the 7-bit ASCII character space.
656 	 */
657 	public static byte[] encodeASCII(String s) {
658 		final byte[] r = new byte[s.length()];
659 		for (int k = r.length - 1; k >= 0; k--) {
660 			final char c = s.charAt(k);
661 			if (c > 127)
662 				throw new IllegalArgumentException(MessageFormat.format(JGitText.get().notASCIIString, s));
663 			r[k] = (byte) c;
664 		}
665 		return r;
666 	}
667 
668 	/**
669 	 * Convert a string to a byte array in the standard character encoding.
670 	 *
671 	 * @param str
672 	 *            the string to convert. May contain any Unicode characters.
673 	 * @return a byte array representing the requested string, encoded using the
674 	 *         default character encoding (UTF-8).
675 	 * @see #CHARACTER_ENCODING
676 	 */
677 	public static byte[] encode(String str) {
678 		final ByteBuffer bb = UTF_8.encode(str);
679 		final int len = bb.limit();
680 		if (bb.hasArray() && bb.arrayOffset() == 0) {
681 			final byte[] arr = bb.array();
682 			if (arr.length == len)
683 				return arr;
684 		}
685 
686 		final byte[] arr = new byte[len];
687 		bb.get(arr);
688 		return arr;
689 	}
690 
691 	static {
692 		if (OBJECT_ID_LENGTH != newMessageDigest().getDigestLength())
693 			throw new LinkageError(JGitText.get().incorrectOBJECT_ID_LENGTH);
694 		CHARSET = UTF_8;
695 		CHARACTER_ENCODING = UTF_8.name();
696 	}
697 
698 	/** name of the file containing the commit msg for a merge commit */
699 	public static final String MERGE_MSG = "MERGE_MSG";
700 
701 	/** name of the file containing the IDs of the parents of a merge commit */
702 	public static final String MERGE_HEAD = "MERGE_HEAD";
703 
704 	/** name of the file containing the ID of a cherry pick commit in case of conflicts */
705 	public static final String CHERRY_PICK_HEAD = "CHERRY_PICK_HEAD";
706 
707 	/** name of the file containing the commit msg for a squash commit */
708 	public static final String SQUASH_MSG = "SQUASH_MSG";
709 
710 	/** name of the file containing the ID of a revert commit in case of conflicts */
711 	public static final String REVERT_HEAD = "REVERT_HEAD";
712 
713 	/**
714 	 * name of the ref ORIG_HEAD used by certain commands to store the original
715 	 * value of HEAD
716 	 */
717 	public static final String ORIG_HEAD = "ORIG_HEAD";
718 
719 	/**
720 	 * Name of the file in which git commands and hooks store and read the
721 	 * message prepared for the upcoming commit.
722 	 *
723 	 * @since 4.0
724 	 */
725 	public static final String COMMIT_EDITMSG = "COMMIT_EDITMSG";
726 
727 	/**
728 	 * Well-known object ID for the empty blob.
729 	 *
730 	 * @since 0.9.1
731 	 */
732 	public static final ObjectId EMPTY_BLOB_ID = ObjectId
733 			.fromString("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391");
734 
735 	/**
736 	 * Well-known object ID for the empty tree.
737 	 *
738 	 * @since 5.1
739 	 */
740 	public static final ObjectId EMPTY_TREE_ID = ObjectId
741 			.fromString("4b825dc642cb6eb9a060e54bf8d69288fbee4904");
742 
743 	/**
744 	 * Suffix of lock file name
745 	 *
746 	 * @since 4.7
747 	 */
748 	public static final String LOCK_SUFFIX = ".lock"; //$NON-NLS-1$
749 
750 	private Constants() {
751 		// Hide the default constructor
752 	}
753 }