Skip to main content

Module index

Module index 

Source
Expand description

Git index (staging area) reading and writing.

The index file (.git/index) stores the current state of the staging area. It uses a binary format with a 12-byte header, fixed-size index entries, and optional extensions, followed by a trailing SHA-1 over the whole file.

§Format version

This implementation supports index versions 2 and 3. Requests for version 4 currently fall back to a non-compressed index on write because path compression is not yet implemented.

§References

See Documentation/technical/index-format.txt in the Git source tree for the authoritative format specification.

Structs§

Index
The in-memory representation of the Git index file.
IndexEntry
A single entry in the Git index.
IndexLoadOptions
Options for loading an index from disk.

Constants§

MODE_EXECUTABLE
File mode for an executable file.
MODE_GITLINK
File mode for a gitlink (submodule).
MODE_REGULAR
File mode for a regular (non-executable) file.
MODE_SYMLINK
File mode for a symbolic link.
MODE_TREE
File mode for a directory (tree) entry — only used in tree objects, not index.

Functions§

entry_from_metadata
Build an IndexEntry from already-obtained metadata.
entry_from_stat
Build an IndexEntry by stat-ing a file on disk.
get_index_format_from_env
Read GIT_INDEX_VERSION and return the requested version.
normalize_mode
Convert a stat mode to the Git index mode, normalised to one of the known constants (MODE_REGULAR, MODE_EXECUTABLE, MODE_SYMLINK).