class
Agate::Index
- Agate::Index
- Reference
- Object
Overview
The git index (staging area) for tracking file changes.
Included Modules
- Enumerable(Agate::IndexEntry)
Defined in:
agate/index.crInstance Method Summary
-
#<<(path : String | Path) : Nil
Alias for add.
-
#[](index : Int32) : IndexEntry
Returns the entry at the given index (0-based).
-
#[](path : String, stage : Int32 = 0) : IndexEntry
Returns the entry for the given path and stage.
-
#add(path : String | Path) : Nil
Stages a file by its path (relative to the workdir).
-
#add_all(pathspecs : Array(String)) : Nil
Stages all files matching the given pathspecs.
-
#clear : Nil
Clears all entries from the index.
-
#conflict_cleanup : Nil
Removes all conflict entries from the index.
-
#conflict_get(path : String) : Tuple(IndexEntry | Nil, IndexEntry | Nil, IndexEntry | Nil) | Nil
Returns the conflict entries for the given path, or nil if none.
-
#conflict_remove(path : String) : Nil
Removes the conflict entry for the given path.
-
#conflicts : Array(Tuple(IndexEntry | Nil, IndexEntry | Nil, IndexEntry | Nil))
Returns all conflicts as an array of
{ancestor, ours, theirs}tuples. -
#conflicts? : Bool
Returns true if there are unresolved conflicts in the index.
-
#count : Int32
Returns the number of entries in the index.
-
#diff(repo : Repository) : Diff
Diffs this index against the working directory.
-
#each(& : IndexEntry -> ) : Nil
Iterates over all entries.
-
#each_conflict(& : Tuple(IndexEntry | Nil, IndexEntry | Nil, IndexEntry | Nil) -> ) : Nil
Iterates over all conflict entries in the index, yielding
{ancestor, ours, theirs}for each conflicted path. -
#get?(path : String, stage : Int32 = 0) : IndexEntry | Nil
Returns the entry for the given path and stage, or nil.
-
#read_tree(tree) : Nil
Populates the index from a tree.
-
#reload : Nil
Re-reads the index from disk (force reload).
-
#remove(path : String | Path) : Nil
Removes a file from the index by path.
-
#remove_all(pathspecs : Array(String)) : Nil
Removes all files matching the given pathspecs from the index.
-
#remove_dir(dir : String, stage : Int32 = 0) : Nil
Removes all index entries under the given directory.
-
#write : Nil
Writes the index to disk.
-
#write_tree : OID
Writes the index as a tree to the repository, returning the tree OID.
Instance Method Detail
Returns the entry for the given path and stage. Raises if not found.
Returns the conflict entries for the given path, or nil if none.
Returns {ancestor, ours, theirs} as IndexEntry tuples.
Returns all conflicts as an array of {ancestor, ours, theirs} tuples.
Diffs this index against the working directory.
Convenience wrapper for Diff.index_to_workdir(repo).
diff = repo.index.diff(repo)
diff.each { |delta| puts delta.new_file.path }
Iterates over all conflict entries in the index, yielding
{ancestor, ours, theirs} for each conflicted path.
Returns the entry for the given path and stage, or nil.
Removes all files matching the given pathspecs from the index.
Removes all index entries under the given directory.
index.remove_dir("src/old")
Writes the index as a tree to the repository, returning the tree OID.