Class GitIdentifiers.DirectoryEntry

java.lang.Object
org.apache.commons.codec.digest.GitIdentifiers.DirectoryEntry
All Implemented Interfaces:
Comparable<GitIdentifiers.DirectoryEntry>
Enclosing class:
GitIdentifiers

static class GitIdentifiers.DirectoryEntry extends Object implements Comparable<GitIdentifiers.DirectoryEntry>
Represents a single entry in a Git tree object.

A Git tree object encodes a directory snapshot. Each entry holds:

  • a GitIdentifiers.FileMode that determines the Unix file mode (e.g. 100644 for a regular file),
  • the entry name (file or directory name, without a path separator),
  • the raw object id of the referenced blob or sub-tree.

Entries are ordered by compareTo(org.apache.commons.codec.digest.GitIdentifiers.DirectoryEntry) using Git's tree-sort rule: names are compared as unsigned UTF-8 bytes, and directory names are compared as if they ended with '/', so that foo/ sorts after foobar. Comparing the UTF-8 bytes rather than the Java String matches Git's order for names outside the Basic Multilingual Plane, whose UTF-16 code units do not sort in code point order.

See Also:
  • Field Details

    • name

      private final String name
      The entry name (file or directory name, no path separator).
    • rawObjectId

      private final byte[] rawObjectId
      The raw object id of the referenced blob or sub-tree.
    • sortKey

      private final byte[] sortKey
      The key used for ordering entries within a tree object, as the UTF-8 bytes Git itself compares.

      Git appends '/' to directory names before comparing.

    • type

      private final GitIdentifiers.FileMode type
      The Git object type, which determines the Unix file-mode prefix.
  • Constructor Details

    • DirectoryEntry

      DirectoryEntry(String name, GitIdentifiers.FileMode type, byte[] rawObjectId)
      Constructs a new entry.
      Parameters:
      name - The nonempty entry name, not . or .., without '/', NUL or unpaired surrogates.
      type - The type of the entry, not null.
      rawObjectId - The id of the entry, not null.
  • Method Details