Class GitWrapper

Class Documentation

class GitWrapper

Thin wrapper around libgit2 for common operations.

Public Functions

bool add(const fs::path &path)

Add a file to the repository index.

bool open(const fs::path &path)

Open an existing repository.

DiffResult diff(const gitwrap::commit &oldCommit, const gitwrap::commit &newCommit)

Get a diff between two commits.

MAYBE_BLAME Blame(const fs::path &filepath, const gitwrap::commit &newCommit, const gitwrap::commit &oldCommit)

Run git blame on a file between two commits.

bool commit(git_signature *sign, const std::string &message)

Commit staged changes using the provided signature.

bool log()

Walks the commit history and builds a log.

Returns:

true if the log was built successfully, false otherwise.

bool log(const std::string &branchName)

Walks the commit history of a specific branch and builds a log.

Parameters:

branchName – The name of the branch to log.

Returns:

true if the log was built successfully, false otherwise.

bool close()

Close the repository and free resources.

GitWrapper()

Construct an empty wrapper.

~GitWrapper()

Destructor.

Public Members

git_repository *repo = nullptr
std::optional<gitwrap::logHandle> log_hdl
BRANCH_HANDLE handleBranch

Public Static Functions

static std::string GenTimeStamp()