antis81/libqgit2 — Issue #1: RevisionWalker not working correctly?
Author: antis81
Created: 2011-11-17 03:02:45+00:00
State: open

I did some testcode with the library, but cannot get the revision walker to work. Currently providing a fix hash representing the head commit to start with.

Sample code:

// open the repo
QString repoPath = ;
QGitRepository repo;
err = repo.open(QString("%1").arg(repoPath));
if (err != 0)
{
QMessageBox::critical(0, "Error", "Unable to open Repository!");
return;
}

// lookup commit in test repo by hash of HEAD commit
QGitCommit * commit = new QGitCommit();
err = commit->lookup(&repo,
QGitOId::fromString());

QGitRevWalk revWalker(&repo);
revWalker.sorting(GIT_SORT_TOPOLOGICAL | GIT_SORT_REVERSE);
err = revWalker.push(commit);

QGitCommit *nextCommit;
ui->textCommitLogTest->appendPlainText(QString("Repository history:\n"));
while ((revWalker.next(commit)) == GIT_SUCCESS)
{
// output commit message, author name and email
QString message = commit->message();
git_signature * auth = commit->author()->data();
qDebug() << QString("* %1 (%2 - %3)").arg(message).arg(auth->name).arg(auth->email));
}