SlHelpers
SlGit::Index Class Reference

Index is a representation of a git index. More...

#include <Index.h>

Public Types

using MatchCB = std::function< int(const std::filesystem::path &, const std::string &)>
 A callback for addAll(), removeAll(), updateAll()
 

Public Member Functions

bool read (bool force=true) const noexcept
 Read the index from the disk into this Index.
 
bool write () const noexcept
 Write this Index to disk.
 
bool readTree (const Tree &tree) const noexcept
 Read tree into this Index.
 
std::optional< TreewriteTree (const Repo &repo) const noexcept
 Write this Index as a Tree.
 
size_t entrycount () const noexcept
 Get count of entries in this Index.
 
const git_index_entry * entryByIndex (size_t idx) const noexcept
 Get an entry on the idx-th position.
 
const git_index_entry * entryByPath (const std::filesystem::path &path, git_index_stage_t stage=GIT_INDEX_STAGE_NORMAL) const noexcept
 Get entry corresponding to path (and stage)
 
bool addByPath (const std::filesystem::path &path) const noexcept
 Add path to this Index.
 
bool removeByPath (const std::filesystem::path &path) const noexcept
 Remove path from this Index.
 
int addAll (const std::vector< std::string > &paths, unsigned int flags, const MatchCB *cb=nullptr) const
 Add all paths into this Index. More...
 
int removeAll (const std::vector< std::string > &paths, const MatchCB *cb=nullptr) const
 Remove all paths from this Index. More...
 
int updateAll (const std::vector< std::string > &paths, const MatchCB *cb=nullptr) const
 Update all paths in this Index. More...
 
bool hasConflicts () const noexcept
 Returns true if this index has some conflicts.
 
IndexIterator begin () noexcept
 Get the begin iterator for this Index.
 
IndexIterator end () noexcept
 Get the end iterator for this Index.
 
IndexIterator cbegin () const noexcept
 Get the begin iterator for this Index.
 
IndexIterator cend () const noexcept
 Get the end iterator for this Index.
 
GitTy * index () const noexcept
 Get the stored pointer to libgit2's git_index.
 
 operator GitTy * () const noexcept
 Alias for index() – implicit conversion.
 

Static Public Member Functions

static std::optional< Indexopen (const std::filesystem::path &path) noexcept
 Load an index at into a new Index.
 
static std::optional< Indexcreate () noexcept
 Create a new Index.
 

Friends

class Repo
 

Detailed Description

Index is a representation of a git index.

Member Function Documentation

◆ addAll()

int SlGit::Index::addAll ( const std::vector< std::string > &  paths,
unsigned int  flags,
const MatchCB cb = nullptr 
) const

Add all paths into this Index.

Parameters
pathsPaths to add
flagsCombination of git_index_add_option_t
cbCallback for each added/updated path (or nullptr)
Returns
0 on success, negative callback return value, or error code.

◆ removeAll()

int SlGit::Index::removeAll ( const std::vector< std::string > &  paths,
const MatchCB cb = nullptr 
) const

Remove all paths from this Index.

Parameters
pathsPaths to remove
cbCallback for each removed path (or nullptr)
Returns
0 on success, negative callback return value, or error code.

◆ updateAll()

int SlGit::Index::updateAll ( const std::vector< std::string > &  paths,
const MatchCB cb = nullptr 
) const

Update all paths in this Index.

Parameters
pathsPaths to update
cbCallback for each updated path (or nullptr)
Returns
0 on success, negative callback return value, or error code.

The documentation for this class was generated from the following file: