Program Listing for File AddController.cpp
↰ Return to documentation for file (include\editor\featureWrapper\GitWrap\Add\AddController.cpp
)
#include "AddController.hpp"
#include "PDJE_LOG_SETTER.hpp"
AddController::~AddController()
{
if (index) {
git_index_free(index);
}
}
bool
AddController::open(git_repository *repo)
{
if (git_repository_index(&index, repo) != 0) {
critlog("failed to open or create git repository. from AddController "
"open. Errmsg; ");
critlog(git_error_last()->message);
return false;
}
return true;
}
bool
AddController::addFile(const fs::path &path)
{
std::string safeStr = path.generic_string();
if (!index) {
critlog("git_index is null. tried from AddController addFile.");
critlog(path.generic_string());
return false;
}
if (git_index_add_bypath(index, safeStr.c_str()) != 0) {
critlog("failed to add index by path. from AddController addFile. "
"ErrPath & errmsg: ");
critlog(path.generic_string());
critlog(git_error_last()->message);
return false;
}
if (git_index_write(index) != 0) {
critlog("failed to write index. from AddController addFile. ErrPath & "
"errmsg: ");
critlog(path.generic_string());
critlog(git_error_last()->message);
return false;
}
return true;
}