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