{
    "content": [
        {
            "type": "text",
            "text": "# gitformat-index (man)\n\n## NAME\n\ngitformat-index - Git index format\n\n## SYNOPSIS\n\n$GITDIR/index\n\n## DESCRIPTION\n\nGit index format\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **THE GIT INDEX FILE HAS THE FOLLOWING FORMAT**\n- **INDEX ENTRY**\n- **EXTENSIONS** (3 subsections)\n- **UNTRACKED CACHE**\n- **FILE SYSTEM MONITOR CACHE**\n- **END OF INDEX ENTRY**\n- **INDEX ENTRY OFFSET TABLE**\n- **SPARSE DIRECTORY ENTRIES**\n- **GIT**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "gitformat-index",
        "section": "",
        "mode": "man",
        "summary": "gitformat-index - Git index format",
        "synopsis": "$GITDIR/index",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "THE GIT INDEX FILE HAS THE FOLLOWING FORMAT",
                "lines": 32,
                "subsections": []
            },
            {
                "name": "INDEX ENTRY",
                "lines": 104,
                "subsections": []
            },
            {
                "name": "EXTENSIONS",
                "lines": 1,
                "subsections": [
                    {
                        "name": "Cache tree",
                        "lines": 58
                    },
                    {
                        "name": "Resolve undo",
                        "lines": 24
                    },
                    {
                        "name": "Split index",
                        "lines": 27
                    }
                ]
            },
            {
                "name": "UNTRACKED CACHE",
                "lines": 54,
                "subsections": []
            },
            {
                "name": "FILE SYSTEM MONITOR CACHE",
                "lines": 19,
                "subsections": []
            },
            {
                "name": "END OF INDEX ENTRY",
                "lines": 20,
                "subsections": []
            },
            {
                "name": "INDEX ENTRY OFFSET TABLE",
                "lines": 16,
                "subsections": []
            },
            {
                "name": "SPARSE DIRECTORY ENTRIES",
                "lines": 10,
                "subsections": []
            },
            {
                "name": "GIT",
                "lines": 3,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "gitformat-index - Git index format\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "$GITDIR/index\n\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "Git index format\n",
                "subsections": []
            },
            "THE GIT INDEX FILE HAS THE FOLLOWING FORMAT": {
                "content": "All binary numbers are in network byte order.\nIn a repository using the traditional SHA-1, checksums and object IDs\n(object names) mentioned below are all computed using SHA-1.  Similarly,\nin SHA-256 repositories, these values are computed using SHA-256.\nVersion 2 is described here unless stated otherwise.\n\n•   A 12-byte header consisting of\n\n4-byte signature:\nThe signature is { 'D', 'I', 'R', 'C' } (stands for \"dircache\")\n\n4-byte version number:\nThe current supported versions are 2, 3 and 4.\n\n32-bit number of index entries.\n\n•   A number of sorted index entries (see below).\n\n•   Extensions\n\nExtensions are identified by signature. Optional extensions can\nbe ignored if Git does not understand them.\n\n4-byte extension signature. If the first byte is 'A'..'Z' the\nextension is optional and can be ignored.\n\n32-bit size of the extension\n\nExtension data\n\n•   Hash checksum over the content of the index file before this checksum.\n",
                "subsections": []
            },
            "INDEX ENTRY": {
                "content": "Index entries are sorted in ascending order on the name field,\ninterpreted as a string of unsigned bytes (i.e. memcmp() order, no\nlocalization, no special casing of directory separator '/'). Entries\nwith the same name are sorted by their stage field.\n\nAn index entry typically represents a file. However, if sparse-checkout\nis enabled in cone mode (`core.sparseCheckoutCone` is enabled) and the\n`extensions.sparseIndex` extension is enabled, then the index may\ncontain entries for directories outside of the sparse-checkout definition.\nThese entries have mode `040000`, include the `SKIPWORKTREE` bit, and\nthe path ends in a directory separator.\n\n32-bit ctime seconds, the last time a file's metadata changed\nthis is stat(2) data\n\n32-bit ctime nanosecond fractions\nthis is stat(2) data\n\n32-bit mtime seconds, the last time a file's data changed\nthis is stat(2) data\n\n32-bit mtime nanosecond fractions\nthis is stat(2) data\n\n32-bit dev\nthis is stat(2) data\n\n32-bit ino\nthis is stat(2) data\n\n32-bit mode, split into (high to low bits)\n\n16-bit unused, must be zero\n\n4-bit object type\nvalid values in binary are 1000 (regular file), 1010 (symbolic link)\nand 1110 (gitlink)\n\n3-bit unused, must be zero\n\n9-bit unix permission. Only 0755 and 0644 are valid for regular files.\nSymbolic links and gitlinks have value 0 in this field.\n\n32-bit uid\nthis is stat(2) data\n\n32-bit gid\nthis is stat(2) data\n\n32-bit file size\nThis is the on-disk size from stat(2), truncated to 32-bit.\n\nObject name for the represented object\n\nA 16-bit 'flags' field split into (high to low bits)\n\n1-bit assume-valid flag\n\n1-bit extended flag (must be zero in version 2)\n\n2-bit stage (during merge)\n\n12-bit name length if the length is less than 0xFFF; otherwise 0xFFF\nis stored in this field.\n\n(Version 3 or later) A 16-bit field, only applicable if the\n\"extended flag\" above is 1, split into (high to low bits).\n\n1-bit reserved for future\n\n1-bit skip-worktree flag (used by sparse checkout)\n\n1-bit intent-to-add flag (used by \"git add -N\")\n\n13-bit unused, must be zero\n\nEntry path name (variable length) relative to top level directory\n(without leading slash). '/' is used as path separator. The special\npath components \".\", \"..\" and \".git\" (without quotes) are disallowed.\nTrailing slash is also disallowed.\n\nThe exact encoding is undefined, but the '.' and '/' characters\nare encoded in 7-bit ASCII and the encoding cannot contain a NUL\nbyte (iow, this is a UNIX pathname).\n\n(Version 4) In version 4, the entry path name is prefix-compressed\nrelative to the path name for the previous entry (the very first\nentry is encoded as if the path name for the previous entry is an\nempty string).  At the beginning of an entry, an integer N in the\nvariable width encoding (the same encoding as the offset is encoded\nfor OFSDELTA pack entries; see linkgit:gitformat-pack[5]) is stored, followed\nby a NUL-terminated string S.  Removing N bytes from the end of the\npath name for the previous entry, and replacing it with the string S\nyields the path name for this entry.\n\n1-8 nul bytes as necessary to pad the entry to a multiple of eight bytes\nwhile keeping the name NUL-terminated.\n\n(Version 4) In version 4, the padding after the pathname does not\nexist.\n\nInterpretation of index entries in split index mode is completely\ndifferent. See below for details.\n",
                "subsections": []
            },
            "EXTENSIONS": {
                "content": "",
                "subsections": [
                    {
                        "name": "Cache tree",
                        "content": "Since the index does not record entries for directories, the cache\nentries cannot describe tree objects that already exist in the object\ndatabase for regions of the index that are unchanged from an existing\ncommit. The cache tree extension stores a recursive tree structure that\ndescribes the trees that already exist and completely match sections of\nthe cache entries. This speeds up tree object generation from the index\nfor a new commit by only computing the trees that are \"new\" to that\ncommit. It also assists when comparing the index to another tree, such\nas `HEAD^{tree}`, since sections of the index can be skipped when a tree\ncomparison demonstrates equality.\n\nThe recursive tree structure uses nodes that store a number of cache\nentries, a list of subnodes, and an object ID (OID). The OID references\nthe existing tree for that node, if it is known to exist. The subnodes\ncorrespond to subdirectories that themselves have cache tree nodes. The\nnumber of cache entries corresponds to the number of cache entries in\nthe index that describe paths within that tree's directory.\n\nThe extension tracks the full directory structure in the cache tree\nextension, but this is generally smaller than the full cache entry list.\n\nWhen a path is updated in index, Git invalidates all nodes of the\nrecursive cache tree corresponding to the parent directories of that\npath. We store these tree nodes as being \"invalid\" by using \"-1\" as the\nnumber of cache entries. Invalid nodes still store a span of index\nentries, allowing Git to focus its efforts when reconstructing a full\ncache tree.\n\nThe signature for this extension is { 'T', 'R', 'E', 'E' }.\n\nA series of entries fill the entire extension; each of which\nconsists of:\n\n•   NUL-terminated path component (relative to its parent directory);\n\n•   ASCII decimal number of entries in the index that is covered by the tree this entry\nrepresents (entrycount);\n\n•   A space (ASCII 32);\n\n•   ASCII decimal number that represents the number of subtrees this tree has;\n\n•   A newline (ASCII 10); and\n\n•   Object name for the object that would result from writing this span of index as a tree.\n\nAn entry can be in an invalidated state and is represented by having\na negative number in the entrycount field. In this case, there is no\nobject name and the next entry starts immediately after the newline.\nWhen writing an invalid entry, -1 should always be used as entrycount.\n\nThe entries are written out in the top-down, depth-first order.  The\nfirst entry represents the root level of the repository, followed by the\nfirst subtree--let's call this A--of the root level (with its name\nrelative to the root level), followed by the first subtree of A (with\nits name relative to A), and so on. The specified number of subtrees\nindicates when the current level of the recursive stack is complete.\n"
                    },
                    {
                        "name": "Resolve undo",
                        "content": "A conflict is represented in the index as a set of higher stage entries.\nWhen a conflict is resolved (e.g. with \"git add path\"), these higher\nstage entries will be removed and a stage-0 entry with proper resolution\nis added.\n\nWhen these higher stage entries are removed, they are saved in the\nresolve undo extension, so that conflicts can be recreated (e.g. with\n\"git checkout -m\"), in case users want to redo a conflict resolution\nfrom scratch.\n\nThe signature for this extension is { 'R', 'E', 'U', 'C' }.\n\nA series of entries fill the entire extension; each of which\nconsists of:\n\n•   NUL-terminated pathname the entry describes (relative to the root of the repository, i.e.\nfull pathname);\n\n•   Three NUL-terminated ASCII octal numbers, entry mode of entries in stage 1 to 3 (a\nmissing stage is represented by \"0\" in this field); and\n\n•   At most three object names of the entry in stages from 1 to 3 (nothing is written for a\nmissing stage).\n"
                    },
                    {
                        "name": "Split index",
                        "content": "In split index mode, the majority of index entries could be stored\nin a separate file. This extension records the changes to be made on\ntop of that to produce the final index.\n\nThe signature for this extension is { 'l', 'i', 'n', 'k' }.\n\nThe extension consists of:\n\n•   Hash of the shared index file. The shared index file path is $GITDIR/sharedindex.<hash>.\nIf all bits are zero, the index does not require a shared index file.\n\n•   An ewah-encoded delete bitmap, each bit represents an entry in the shared index. If a bit\nis set, its corresponding entry in the shared index will be removed from the final index.\nNote, because a delete operation changes index entry positions, but we do need original\npositions in replace phase, it’s best to just mark entries for removal, then do a mass\ndeletion after replacement.\n\n•   An ewah-encoded replace bitmap, each bit represents an entry in the shared index. If a\nbit is set, its corresponding entry in the shared index will be replaced with an entry in\nthis index file. All replaced entries are stored in sorted order in this index. The first\n\"1\" bit in the replace bitmap corresponds to the first index entry, the second \"1\" bit to\nthe second entry and so on. Replaced entries may have empty path names to save space.\n\nThe remaining index entries after replaced ones will be added to the\nfinal index. These added entries are also sorted by entry name then\nstage.\n"
                    }
                ]
            },
            "UNTRACKED CACHE": {
                "content": "Untracked cache saves the untracked file list and necessary data to\nverify the cache. The signature for this extension is { 'U', 'N',\n'T', 'R' }.\n\nThe extension starts with\n\n•   A sequence of NUL-terminated strings, preceded by the size of the sequence in variable\nwidth encoding. Each string describes the environment where the cache can be used.\n\n•   Stat data of $GITDIR/info/exclude. See \"Index entry\" section from ctime field until\n\"file size\".\n\n•   Stat data of core.excludesFile\n\n•   32-bit dirflags (see struct dirstruct)\n\n•   Hash of $GITDIR/info/exclude. A null hash means the file does not exist.\n\n•   Hash of core.excludesFile. A null hash means the file does not exist.\n\n•   NUL-terminated string of per-dir exclude file name. This usually is \".gitignore\".\n\n•   The number of following directory blocks, variable width encoding. If this number is\nzero, the extension ends here with a following NUL.\n\n•   A number of directory blocks in depth-first-search order, each consists of\n\n•   The number of untracked entries, variable width encoding.\n\n•   The number of sub-directory blocks, variable width encoding.\n\n•   The directory name terminated by NUL.\n\n•   A number of untracked file/dir names terminated by NUL.\n\nThe remaining data of each directory block is grouped by type:\n\n•   An ewah bitmap, the n-th bit marks whether the n-th directory has valid untracked cache\nentries.\n\n•   An ewah bitmap, the n-th bit records \"check-only\" bit of readdirectoryrecursive() for\nthe n-th directory.\n\n•   An ewah bitmap, the n-th bit indicates whether hash and stat data is valid for the n-th\ndirectory and exists in the next data.\n\n•   An array of stat data. The n-th data corresponds with the n-th \"one\" bit in the previous\newah bitmap.\n\n•   An array of hashes. The n-th hash corresponds with the n-th \"one\" bit in the previous\newah bitmap.\n\n•   One NUL.\n",
                "subsections": []
            },
            "FILE SYSTEM MONITOR CACHE": {
                "content": "The file system monitor cache tracks files for which the core.fsmonitor\nhook has told us about changes.  The signature for this extension is\n{ 'F', 'S', 'M', 'N' }.\n\nThe extension starts with\n\n•   32-bit version number: the current supported versions are 1 and 2.\n\n•   (Version 1) 64-bit time: the extension data reflects all changes through the given time\nwhich is stored as the nanoseconds elapsed since midnight, January 1, 1970.\n\n•   (Version 2) A null terminated string: an opaque token defined by the file system monitor\napplication. The extension data reflects all changes relative to that token.\n\n•   32-bit bitmap size: the size of the CEFSMONITORVALID bitmap.\n\n•   An ewah bitmap, the n-th bit indicates whether the n-th index entry is not\nCEFSMONITORVALID.\n",
                "subsections": []
            },
            "END OF INDEX ENTRY": {
                "content": "The End of Index Entry (EOIE) is used to locate the end of the variable\nlength index entries and the beginning of the extensions. Code can take\nadvantage of this to quickly locate the index extensions without having\nto parse through all of the index entries.\n\nBecause it must be able to be loaded before the variable length cache\nentries and other index extensions, this extension must be written last.\nThe signature for this extension is { 'E', 'O', 'I', 'E' }.\n\nThe extension consists of:\n\n•   32-bit offset to the end of the index entries\n\n•   Hash over the extension types and their sizes (but not their contents). E.g. if we have\n\"TREE\" extension that is N-bytes long, \"REUC\" extension that is M-bytes long, followed by\n\"EOIE\", then the hash would be:\n\nHash(\"TREE\" + <binary representation of N> +\n\"REUC\" + <binary representation of M>)\n",
                "subsections": []
            },
            "INDEX ENTRY OFFSET TABLE": {
                "content": "The Index Entry Offset Table (IEOT) is used to help address the CPU\ncost of loading the index by enabling multi-threading the process of\nconverting cache entries from the on-disk format to the in-memory format.\nThe signature for this extension is { 'I', 'E', 'O', 'T' }.\n\nThe extension consists of:\n\n•   32-bit version (currently 1)\n\n•   A number of index offset entries each consisting of:\n\n•   32-bit offset from the beginning of the file to the first cache entry in this block of\nentries.\n\n•   32-bit count of cache entries in this block\n",
                "subsections": []
            },
            "SPARSE DIRECTORY ENTRIES": {
                "content": "When using sparse-checkout in cone mode, some entire directories within\nthe index can be summarized by pointing to a tree object instead of the\nentire expanded list of paths within that tree. An index containing such\nentries is a \"sparse index\". Index format versions 4 and less were not\nimplemented with such entries in mind. Thus, for these versions, an\nindex containing sparse directory entries will include this extension\nwith signature { 's', 'd', 'i', 'r' }. Like the split-index extension,\ntools should avoid interacting with a sparse index unless they understand\nthis extension.\n",
                "subsections": []
            },
            "GIT": {
                "content": "Part of the git(1) suite\n\nGit 2.43.0                                   07/02/2025                           GITFORMAT-INDEX(5)",
                "subsections": []
            }
        }
    }
}