Skip to content

Instantly share code, notes, and snippets.

@shibukawa
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shibukawa/82340902063970e68ddd to your computer and use it in GitHub Desktop.
Save shibukawa/82340902063970e68ddd to your computer and use it in GitHub Desktop.
libqgit2

libqgit2

// open
auto repo = new Repository();
repo->open("/Users/shibukawa/dev/repo");

// Does HEAD exist?
repo->isheadUnborn(); => true if there are no commit

// get HEAD
auto head = repo->head();

// get all commits
auto repo->lookupCommit(head.target());

size_t parentCount = commit.parentCount();
for (size_t i = 0; i < parentCount; i++) {
    parents.append(commit.parent(i));
}

// get folder entries in commit
auto entryCount = tree.entryCount();
for (size_t i = 0; i < entryCount; i++) {
    auto childEntry = tree.entryByIndex(i);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment