Xgit v0.1.3 Xgit.Core.DirCache View Source
A directory cache records the current (intended) contents of a working tree when last scanned or created by git.
In Xgit, the DirCache
structure is an abstract, in-memory data structure
without any tie to a specific persistence mechanism. Persistence is implemented
by a specific implementation of the Xgit.Repository
behaviour.
This content is commonly persisted on disk as an index
file at the root of
the git tree. The module Xgit.Repository.WorkingTree.ParseIndexFile
can
parse that file format.
Changes in the working tree can be detected by comparing the modification times to the cached modification time within the dir cache.
Index files are also used during merges, where the merge happens within the index file first, and the working directory is updated as a post-merge step. Conflicts are stored in the index file to allow tool (and human) based resolutions to be easily performed.
Link to this section Summary
Types
This struct describes an entire working tree as understood by git.
Version number for an index file.
Functions
Returns a dir cache that is the canonical "empty" dir cache (i.e. contains no entries).
Return true
if the value is a DirCache
struct that is valid.
Link to this section Types
t()
View Source
t() :: %Xgit.Core.DirCache{
entries: [Xgit.Core.DirCache.Entry.t()],
entry_count: non_neg_integer(),
version: version()
}
t() :: %Xgit.Core.DirCache{ entries: [Xgit.Core.DirCache.Entry.t()], entry_count: non_neg_integer(), version: version() }
This struct describes an entire working tree as understood by git.
Struct Members
:version
: the version number as read from disk (typically 2, 3, or 4):entry_count
: the number of items inentries
:entries
: a list ofEntry
structs in sorted order:extensions
: a list ofExtension
structs (not yet implemented)
version()
View Source
version() :: 2..4
version() :: 2..4
Version number for an index file.
Link to this section Functions
empty()
View Source
empty() :: t()
empty() :: t()
Returns a dir cache that is the canonical "empty" dir cache (i.e. contains no entries).
valid?(dir_cache) View Source
Return true
if the value is a DirCache
struct that is valid.
All of the following must be true for this to occur:
- The value is a
DirCache
struct. - The version is supported by Xgit. (Currently, only version 2 is supported.)
- The
entry_count
matches the actual number of entries. - The entries are properly sorted.
- All entries are valid, as determined by
Xgit.Core.DirCache.Entry.valid?/1
.