Verifications made by this class only check that the fields of an object are formatted correctly. The ObjectId checksum of the object is not verified, and connectivity links between objects are also not verified. Its assumed that the caller can provide both of these validations on its own.
Instances of this class are not thread safe, but they may be reused to
perform multiple object validations, calling reset() between them to
clear the internal state (e.g. getGitsubmodules())
| Modifier and Type | Class and Description |
|---|---|
| public static enum | ObjectChecker.
Potential issues identified by the checker. |
| Modifier and Type | Field and Description |
|---|---|
| private boolean | |
| public static final byte[] | author
Header "author " |
| private final MutableInteger | |
| public static final byte[] | committer
Header "committer " |
| private static final byte[] | dotGitmodules
Path ".gitmodules" |
| public static final byte[] | encoding
Header "encoding " |
| private EnumSet | |
| private final List | |
| private boolean | |
| public static final byte[] | object
Header "object " |
| public static final byte[] | parent
Header "parent " |
| private ObjectIdSet | |
| public static final byte[] | tag
Header "tag " |
| public static final byte[] | tagger
Header "tagger " |
| private final MutableObjectId | |
| public static final byte[] | tree
Header "tree " |
| public static final byte[] | type
Header "type " |
| private boolean |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | check(int
type of the object. Must be a valid object type code in
objType, byte[] org..the raw data which comprises the object. This should be in the
canonical format (that is the format used to generate the
ObjectId of the object). The array is never modified. raw)Check an object for parsing errors. |
| public void | check(AnyObjectId
identify of the object being checked. id, int type of the object. Must be a valid object type code in
objType, byte[] org..the raw data which comprises the object. This should be in the
canonical format (that is the format used to generate the
ObjectId of the object). The array is never modified. raw)Check an object for parsing errors. |
| public void | |
| public void | |
| public void | checkCommit(AnyObjectId
identity of the object being checked. id, byte[] the commit data. The array is never modified. raw)Check a commit for errors. |
| private boolean | |
| private void | |
| public void | |
| public void | checkPath(byte[]
buffer to scan. raw, int offset to first byte of the name. ptr, int offset to one past last byte of name. end)Check tree path entry for validity. |
| public void | checkPathSegment(byte[]
buffer to scan. raw, int offset to first byte of the name. ptr, int offset to one past last byte of name. end)Check tree path entry for validity. |
| private void | |
| private void | |
| public void | |
| public void | checkTag(AnyObjectId
identity of the object being checked. id, byte[] the tag data. The array is never modified. raw)Check an annotated tag for errors. |
| public void | checkTree(byte[]
the raw tree data. The array is never modified. raw)Check a canonical formatted tree for errors. |
| public void | checkTree(AnyObjectId
identity of the object being checked. id, byte[] the raw tree data. The array is never modified. raw)Check a canonical formatted tree for errors. |
| private boolean | |
| private static boolean | |
| public List | Returns: List of pairs of ids <tree, blob>.Get the list of ".gitmodules" files found in the pack. |
| private ObjectId | |
| private static boolean | |
| private boolean | Returns: true if the filename in buf could be a ".gitmodules" filebyte array to decode buf, int position where a supposed filename is starting start, int position where a supposed filename is ending end, AnyObjectId object id for error reporting id)Check if the filename contained in buf[start:end] could be read as a .gitmodules file when checked out to the working directory. |
| private static boolean | |
| private static boolean | |
| private boolean | |
| private boolean | |
| private boolean | |
| private static boolean | |
| private boolean | |
| private static boolean | |
| private boolean | |
| private boolean | |
| public BlobObjectChecker | Returns: new BlobObjectChecker or null if it's not provided.Create a new |
| private String | |
| private void | |
| public void | |
| private int | |
| public ObjectChecker | Returns: this.if true accept invalid person identity strings. allow)Enable accepting invalid author, committer and tagger identities. |
| public ObjectChecker | Returns: this.allow leading zero mode. allow)Enable accepting leading zero mode in tree entries. |
| public ObjectChecker | Returns: thiserror types to ignore. The caller's set is copied. idsConfigure error types to be ignored across all objects. |
| public ObjectChecker | Returns: thiserror type to ignore. id,true to ignore this error; false to treat the error as an
error and throw. ignore)Add message type to be ignored across all objects. |
| public ObjectChecker | Returns: this.true if Mac OS X name checking should be performed. mac)Restrict trees to only names legal on Mac OS X platforms. |
| public ObjectChecker | Returns: this.true if Windows name checking should be performed. win)Restrict trees to only names legal on Windows platforms. |
| public ObjectChecker | Returns: thiscollection of object names known to be broken in a non-fatal
way that should be ignored by the checker. objects)Enable accepting specific malformed (but not horribly broken) objects. |
| private static String | |
| private static char |
| allowInvalidPersonIdent | back to summary |
|---|---|
| private boolean allowInvalidPersonIdent | |
| author | back to summary |
|---|---|
| public static final byte[] author Header "author " | |
| bufPtr | back to summary |
|---|---|
| private final MutableInteger bufPtr | |
| committer | back to summary |
|---|---|
| public static final byte[] committer Header "committer " | |
| dotGitmodules | back to summary |
|---|---|
| private static final byte[] dotGitmodules Path ".gitmodules" | |
| encoding | back to summary |
|---|---|
| public static final byte[] encoding Header "encoding " | |
| errors | back to summary |
|---|---|
| private EnumSet<ObjectChecker. | |
| gitsubmodules | back to summary |
|---|---|
| private final List<GitmoduleEntry> gitsubmodules | |
| macosx | back to summary |
|---|---|
| private boolean macosx | |
| object | back to summary |
|---|---|
| public static final byte[] object Header "object " | |
| parent | back to summary |
|---|---|
| public static final byte[] parent Header "parent " | |
| skipList | back to summary |
|---|---|
| private ObjectIdSet skipList | |
| tag | back to summary |
|---|---|
| public static final byte[] tag Header "tag " | |
| tagger | back to summary |
|---|---|
| public static final byte[] tagger Header "tagger " | |
| tempId | back to summary |
|---|---|
| private final MutableObjectId tempId | |
| tree | back to summary |
|---|---|
| public static final byte[] tree Header "tree " | |
| type | back to summary |
|---|---|
| public static final byte[] type Header "type " | |
| windows | back to summary |
|---|---|
| private boolean windows | |
| ObjectChecker | back to summary |
|---|---|
| public ObjectChecker() | |
| check | back to summary |
|---|---|
| public void check(int objType, byte[] raw) throws CorruptObjectException Check an object for parsing errors.
| |
| check | back to summary |
|---|---|
| public void check(AnyObjectId id, int objType, byte[] raw) throws CorruptObjectException Check an object for parsing errors.
| |
| checkBlob | back to summary |
|---|---|
| public void checkBlob(byte[] raw) throws CorruptObjectException Check a blob for errors.
This may not be called from PackParser in some cases. Use
| |
| checkCommit | back to summary |
|---|---|
| public void checkCommit(byte[] raw) throws CorruptObjectException Check a commit for errors.
| |
| checkCommit | back to summary |
|---|---|
| public void checkCommit(AnyObjectId id, byte[] raw) throws CorruptObjectException Check a commit for errors.
| |
| checkId | back to summary |
|---|---|
| private boolean checkId(byte[] raw) | |
| checkNotWindowsDevice | back to summary |
|---|---|
| private void checkNotWindowsDevice(byte[] raw, int ptr, int end, AnyObjectId id) throws CorruptObjectException | |
| checkPath | back to summary |
|---|---|
| public void checkPath(String path) throws CorruptObjectException Check tree path entry for validity.
Unlike
| |
| checkPath | back to summary |
|---|---|
| public void checkPath(byte[] raw, int ptr, int end) throws CorruptObjectException Check tree path entry for validity.
Unlike
| |
| checkPathSegment | back to summary |
|---|---|
| public void checkPathSegment(byte[] raw, int ptr, int end) throws CorruptObjectException Check tree path entry for validity.
| |
| checkPathSegment2 | back to summary |
|---|---|
| private void checkPathSegment2(byte[] raw, int ptr, int end, AnyObjectId id) throws CorruptObjectException | |
| checkPersonIdent | back to summary |
|---|---|
| private void checkPersonIdent(byte[] raw, AnyObjectId id) throws CorruptObjectException | |
| checkTag | back to summary |
|---|---|
| public void checkTag(byte[] raw) throws CorruptObjectException Check an annotated tag for errors.
| |
| checkTag | back to summary |
|---|---|
| public void checkTag(AnyObjectId id, byte[] raw) throws CorruptObjectException Check an annotated tag for errors.
| |
| checkTree | back to summary |
|---|---|
| public void checkTree(byte[] raw) throws CorruptObjectException Check a canonical formatted tree for errors.
| |
| checkTree | back to summary |
|---|---|
| public void checkTree(AnyObjectId id, byte[] raw) throws CorruptObjectException Check a canonical formatted tree for errors.
| |
| checkTruncatedIgnorableUTF8 | back to summary |
|---|---|
| private boolean checkTruncatedIgnorableUTF8(byte[] raw, int ptr, int end, AnyObjectId id) throws CorruptObjectException | |
| duplicateName | back to summary |
|---|---|
| private static boolean duplicateName(final byte[] raw, final int thisNamePos, final int thisNameEnd) | |
| getGitsubmodules | back to summary |
|---|---|
| public List Get the list of ".gitmodules" files found in the pack. For each, report its blob id (e.g. to validate its contents) and the tree where it was found (e.g. to check if it is in the root)
| |
| idFor | back to summary |
|---|---|
private ObjectId idFor(int objType, byte[] raw)
| |
| isGit | back to summary |
|---|---|
| private static boolean isGit(byte[] buf, int p) | |
| isGitmodules | back to summary |
|---|---|
| private boolean isGitmodules(byte[] buf, int start, int end, AnyObjectId id) throws CorruptObjectException Check if the filename contained in buf[start:end] could be read as a .gitmodules file when checked out to the working directory. This ought to be a simple comparison, but some filesystems have peculiar rules for normalizing filenames: NTFS has backward-compatibility support for 8.3 synonyms of long file names (see https://web.archive.org/web/20160318181041/https://usn.pw/blog/gen/2015/06/09/filenames/ for details). NTFS is also case-insensitive. MacOS's HFS+ folds away ignorable Unicode characters in addition to case folding.
| |
| isGitTilde1 | back to summary |
|---|---|
| private static boolean isGitTilde1(byte[] buf, int p, int end) | |
| isInvalidOnWindows | back to summary |
|---|---|
| private static boolean isInvalidOnWindows(byte c) | |
| isMacHFSGit | back to summary |
|---|---|
| private boolean isMacHFSGit(byte[] raw, int ptr, int end, AnyObjectId id) throws CorruptObjectException | |
| isMacHFSGitmodules | back to summary |
|---|---|
| private boolean isMacHFSGitmodules(byte[] raw, int ptr, int end, AnyObjectId id) throws CorruptObjectException | |
| isMacHFSPath | back to summary |
|---|---|
| private boolean isMacHFSPath(byte[] raw, int ptr, int end, byte[] path, AnyObjectId id) throws CorruptObjectException | |
| isNormalizedGit | back to summary |
|---|---|
| private static boolean isNormalizedGit(byte[] raw, int ptr, int end) | |
| isNTFSGitmodules | back to summary |
|---|---|
| private boolean isNTFSGitmodules(byte[] buf, int start, int end) | |
| isPositiveDigit | back to summary |
|---|---|
| private static boolean isPositiveDigit(byte b) | |
| match | back to summary |
|---|---|
| private boolean match(byte[] b, byte[] src) | |
| matchLowerCase | back to summary |
|---|---|
| private boolean matchLowerCase(byte[] b, int ptr, byte[] src) | |
| newBlobObjectChecker | back to summary |
|---|---|
| public BlobObjectChecker newBlobObjectChecker() Create a new
| |
| normalize | back to summary |
|---|---|
| private String normalize(byte[] raw, int ptr, int end) | |
| report | back to summary |
|---|---|
| private void report(ObjectChecker. | |
| reset | back to summary |
|---|---|
| public void reset() Reset the invocation-specific state from this instance. Specifically this
clears the list of .gitmodules files encountered (see
| |
| scanPathSegment | back to summary |
|---|---|
| private int scanPathSegment(byte[] raw, int ptr, int end, AnyObjectId id) throws CorruptObjectException | |
| setAllowInvalidPersonIdent | back to summary |
|---|---|
| public ObjectChecker setAllowInvalidPersonIdent(boolean allow) Enable accepting invalid author, committer and tagger identities. Some broken Git versions/libraries allowed users to create commits and tags with invalid formatting between the name, email and timestamp.
| |
| setAllowLeadingZeroFileMode | back to summary |
|---|---|
| public ObjectChecker setAllowLeadingZeroFileMode(boolean allow) Enable accepting leading zero mode in tree entries. Some broken Git libraries generated leading zeros in the mode part of tree entries. This is technically incorrect but gracefully allowed by git-core. JGit rejects such trees by default, but may need to accept them on broken histories.
Same as
| |
| setIgnore | back to summary |
|---|---|
| public ObjectChecker setIgnore(Set<ObjectChecker. Configure error types to be ignored across all objects.
| |
| setIgnore | back to summary |
|---|---|
| public ObjectChecker setIgnore(ObjectChecker. Add message type to be ignored across all objects.
| |
| setSafeForMacOS | back to summary |
|---|---|
| public ObjectChecker setSafeForMacOS(boolean mac) Restrict trees to only names legal on Mac OS X platforms.
Rejects any mixed case forms of reserved names (
| |
| setSafeForWindows | back to summary |
|---|---|
| public ObjectChecker setSafeForWindows(boolean win) Restrict trees to only names legal on Windows platforms.
Also rejects any mixed case forms of reserved names (
| |
| setSkipList | back to summary |
|---|---|
| public ObjectChecker setSkipList(ObjectIdSet objects) Enable accepting specific malformed (but not horribly broken) objects.
| |
| toHexString | back to summary |
|---|---|
| private static String toHexString(byte[] raw, int ptr, int end) | |
| toLower | back to summary |
|---|---|
| private static char toLower(byte b) | |
| Modifier and Type | Field and Description |
|---|---|
| public static final ObjectChecker. | BAD_DATE
(ERROR) Invalid date format in an author/committer line. |
| public static final ObjectChecker. | BAD_EMAIL
(ERROR) Invalid email format in an author/committer line. |
| public static final ObjectChecker. | BAD_OBJECT_SHA1
(ERROR) An object has a bad sha1. |
| public static final ObjectChecker. | BAD_PARENT_SHA1
(ERROR) A commit object has a bad parent sha1. |
| public static final ObjectChecker. | BAD_TIMEZONE
(ERROR) Found an invalid time zone in an author/committer line. |
| public static final ObjectChecker. | BAD_TREE_SHA1
(ERROR) A tree has an invalid format. |
| public static final ObjectChecker. | BAD_UTF8
(ERROR) Byte sequence is not a valid UTF-8 character |
| public static final ObjectChecker. | DUPLICATE_ENTRIES
(ERROR) A tree contains duplicate file entries. |
| public static final ObjectChecker. | EMPTY_NAME
(WARN) A path contains an empty name. |
| public static final ObjectChecker. | FULL_PATHNAME
(WARN) A path contains the full path starting with "/". |
| public static final ObjectChecker. | GITMODULES_BLOB
(ERROR) A non-blob found at .gitmodules. |
| public static final ObjectChecker. | GITMODULES_LARGE
(ERROR) The .gitmodules file is too large to parse. |
| public static final ObjectChecker. | GITMODULES_NAME
(ERROR) A submodule name is invalid. |
| public static final ObjectChecker. | GITMODULES_PARSE
(INFO) Could not parse .gitmodules blob. |
| public static final ObjectChecker. | GITMODULES_PATH
(ERROR) .gitmodules path is invalid. |
| public static final ObjectChecker. | GITMODULES_SYMLINK
(ERROR) .gitmodules is a symlink. |
| public static final ObjectChecker. | GITMODULES_URL
(ERROR) Found an invalid submodule url. |
| public static final ObjectChecker. | HAS_DOT
(WARN) A tree contains an entry named . |
| public static final ObjectChecker. | HAS_DOTDOT
(WARN) A tree contains an entry named .. |
| public static final ObjectChecker. | HAS_DOTGIT
(WARN) A tree contains an entry named .git |
| public static final ObjectChecker. | MISSING_AUTHOR
(ERROR) Author is missing. |
| public static final ObjectChecker. | MISSING_COMMITTER
(ERROR) Committer is missing. |
| public static final ObjectChecker. | MISSING_EMAIL
(ERROR) Email is missing in an author/committer line. |
| public static final ObjectChecker. | MISSING_OBJECT
(ERROR) Missing object line in tag object. |
| public static final ObjectChecker. | MISSING_SPACE_BEFORE_DATE
(ERROR) Missing space before date in an author/committer line. |
| public static final ObjectChecker. | MISSING_TAG_ENTRY
(ERROR) Missing tag line in a tag object. |
| public static final ObjectChecker. | MISSING_TREE
(ERROR) Missing tree line in a commit object. |
| public static final ObjectChecker. | MISSING_TYPE_ENTRY
(ERROR) Missing type line in a tag object. |
| public static final ObjectChecker. | NULL_SHA1
(WARN) Tree contains entries pointing to a null sha1. |
| public static final ObjectChecker. | TREE_NOT_SORTED
(ERROR) A tree is not properly sorted. |
| public static final ObjectChecker. | UNKNOWN_TYPE
(ERROR) Found an unknown object type. |
| public static final ObjectChecker. | WIN32_BAD_NAME
(ERROR) Windows: Invalid name |
| public static final ObjectChecker. | ZERO_PADDED_FILEMODE
(WARN) Found a zero padded filemode in a tree. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public String | |
| public static ObjectChecker. | |
| public static ObjectChecker. |
| BAD_DATE | back to summary |
|---|---|
| public static final ObjectChecker. (ERROR) Invalid date format in an author/committer line. | |
| BAD_EMAIL | back to summary |
|---|---|
| public static final ObjectChecker. (ERROR) Invalid email format in an author/committer line. | |
| BAD_OBJECT_SHA1 | back to summary |
|---|---|
| public static final ObjectChecker. (ERROR) An object has a bad sha1. | |
| BAD_PARENT_SHA1 | back to summary |
|---|---|
| public static final ObjectChecker. (ERROR) A commit object has a bad parent sha1. | |
| BAD_TIMEZONE | back to summary |
|---|---|
| public static final ObjectChecker. (ERROR) Found an invalid time zone in an author/committer line. | |
| BAD_TREE_SHA1 | back to summary |
|---|---|
| public static final ObjectChecker. (ERROR) A tree has an invalid format. | |
| BAD_UTF8 | back to summary |
|---|---|
| public static final ObjectChecker. (ERROR) Byte sequence is not a valid UTF-8 character | |
| DUPLICATE_ENTRIES | back to summary |
|---|---|
| public static final ObjectChecker. (ERROR) A tree contains duplicate file entries. | |
| EMPTY_NAME | back to summary |
|---|---|
| public static final ObjectChecker. (WARN) A path contains an empty name. | |
| FULL_PATHNAME | back to summary |
|---|---|
| public static final ObjectChecker. (WARN) A path contains the full path starting with "/". | |
| GITMODULES_BLOB | back to summary |
|---|---|
| public static final ObjectChecker. (ERROR) A non-blob found at .gitmodules.
| |
| GITMODULES_LARGE | back to summary |
|---|---|
| public static final ObjectChecker. (ERROR) The .gitmodules file is too large to parse.
| |
| GITMODULES_NAME | back to summary |
|---|---|
| public static final ObjectChecker. (ERROR) A submodule name is invalid.
| |
| GITMODULES_PARSE | back to summary |
|---|---|
| public static final ObjectChecker. (INFO) Could not parse .gitmodules blob.
| |
| GITMODULES_PATH | back to summary |
|---|---|
| public static final ObjectChecker. (ERROR) .gitmodules path is invalid.
| |
| GITMODULES_SYMLINK | back to summary |
|---|---|
| public static final ObjectChecker. (ERROR) .gitmodules is a symlink.
| |
| GITMODULES_URL | back to summary |
|---|---|
| public static final ObjectChecker. (ERROR) Found an invalid submodule url.
| |
| HAS_DOT | back to summary |
|---|---|
| public static final ObjectChecker. (WARN) A tree contains an entry named . | |
| HAS_DOTDOT | back to summary |
|---|---|
| public static final ObjectChecker. (WARN) A tree contains an entry named .. | |
| HAS_DOTGIT | back to summary |
|---|---|
| public static final ObjectChecker. (WARN) A tree contains an entry named .git | |
| MISSING_AUTHOR | back to summary |
|---|---|
| public static final ObjectChecker. (ERROR) Author is missing. | |
| MISSING_COMMITTER | back to summary |
|---|---|
| public static final ObjectChecker. (ERROR) Committer is missing. | |
| MISSING_EMAIL | back to summary |
|---|---|
| public static final ObjectChecker. (ERROR) Email is missing in an author/committer line. | |
| MISSING_OBJECT | back to summary |
|---|---|
| public static final ObjectChecker. (ERROR) Missing object line in tag object. | |
| MISSING_SPACE_BEFORE_DATE | back to summary |
|---|---|
| public static final ObjectChecker. (ERROR) Missing space before date in an author/committer line. | |
| MISSING_TAG_ENTRY | back to summary |
|---|---|
| public static final ObjectChecker. (ERROR) Missing tag line in a tag object. | |
| MISSING_TREE | back to summary |
|---|---|
| public static final ObjectChecker. (ERROR) Missing tree line in a commit object. | |
| MISSING_TYPE_ENTRY | back to summary |
|---|---|
| public static final ObjectChecker. (ERROR) Missing type line in a tag object. | |
| NULL_SHA1 | back to summary |
|---|---|
| public static final ObjectChecker. (WARN) Tree contains entries pointing to a null sha1. | |
| TREE_NOT_SORTED | back to summary |
|---|---|
| public static final ObjectChecker. (ERROR) A tree is not properly sorted. | |
| UNKNOWN_TYPE | back to summary |
|---|---|
| public static final ObjectChecker. (ERROR) Found an unknown object type. | |
| WIN32_BAD_NAME | back to summary |
|---|---|
| public static final ObjectChecker. (ERROR) Windows: Invalid name | |
| ZERO_PADDED_FILEMODE | back to summary |
|---|---|
| public static final ObjectChecker. (WARN) Found a zero padded filemode in a tree. | |
| ErrorType | back to summary |
|---|---|
| private ErrorType() | |
| getMessageId | back to summary |
|---|---|
| public String getMessageId() Get camelCaseVersion of the name
| |
| valueOf | back to summary |
|---|---|
| public static ObjectChecker. | |
| values | back to summary |
|---|---|
| public static ObjectChecker. | |