class Agate::Index

Overview

The git index (staging area) for tracking file changes.

Included Modules

Defined in:

agate/index.cr

Instance Method Summary

Instance Method Detail

def <<(path : String | Path) : Nil #

Alias for add.


[View source]
def [](index : Int32) : IndexEntry #

Returns the entry at the given index (0-based).


[View source]
def [](path : String, stage : Int32 = 0) : IndexEntry #

Returns the entry for the given path and stage. Raises if not found.


[View source]
def add(path : String | Path) : Nil #

Stages a file by its path (relative to the workdir).


[View source]
def add_all(pathspecs : Array(String)) : Nil #

Stages all files matching the given pathspecs.


[View source]
def clear : Nil #

Clears all entries from the index.


[View source]
def conflict_cleanup : Nil #

Removes all conflict entries from the index.


[View source]
def conflict_get(path : String) : Tuple(IndexEntry | Nil, IndexEntry | Nil, IndexEntry | Nil) | Nil #

Returns the conflict entries for the given path, or nil if none. Returns {ancestor, ours, theirs} as IndexEntry tuples.


[View source]
def conflict_remove(path : String) : Nil #

Removes the conflict entry for the given path.


[View source]
def conflicts : Array(Tuple(IndexEntry | Nil, IndexEntry | Nil, IndexEntry | Nil)) #

Returns all conflicts as an array of {ancestor, ours, theirs} tuples.


[View source]
def conflicts? : Bool #

Returns true if there are unresolved conflicts in the index.


[View source]
def count : Int32 #

Returns the number of entries in the index.


[View source]
def diff(repo : Repository) : Diff #

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 }

[View source]
def each(& : IndexEntry -> ) : Nil #

Iterates over all entries.


[View source]
def 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.


[View source]
def get?(path : String, stage : Int32 = 0) : IndexEntry | Nil #

Returns the entry for the given path and stage, or nil.


[View source]
def read_tree(tree) : Nil #

Populates the index from a tree.


[View source]
def reload : Nil #

Re-reads the index from disk (force reload).


[View source]
def remove(path : String | Path) : Nil #

Removes a file from the index by path.


[View source]
def remove_all(pathspecs : Array(String)) : Nil #

Removes all files matching the given pathspecs from the index.


[View source]
def remove_dir(dir : String, stage : Int32 = 0) : Nil #

Removes all index entries under the given directory.

index.remove_dir("src/old")

[View source]
def write : Nil #

Writes the index to disk.


[View source]
def write_tree : OID #

Writes the index as a tree to the repository, returning the tree OID.


[View source]