For this project I use libgit2. I can create successful clones of Repositories. I can see changes with "git status" from the command line, but when I try to fetch changes from the Remote Repository, my program doesn't emit any errors, but doesn't work.
bool Repository::fetchRemoteRepository(QString repos)
{
git_repository *repo = nullptr;
int error = git_repository_open(&repo, repos.toStdString().c_str());
if (error < 0)
{
const git_error *err = giterr_last();
mError = QString(err->message);
git_repository_free(repo);
return false;
}
git_remote *remote;
error = git_remote_lookup(&remote, repo, "origin");
if (error < 0)
{
const git_error *err = giterr_last();
mError = QString(err->message);
git_remote_free(remote);
git_repository_free(repo);
return false;
}
error = git_remote_fetch(remote, NULL, NULL, NULL);
if (error < 0)
{
const git_error *err = giterr_last();
mError = QString(err->message);
git_remote_free(remote);
git_repository_free(repo);
return false;
}
git_remote_free(remote);
git_repository_free(repo);
return true;
}
I use libgit2 0.26.0