如何使用LibGit2 C++列出分支?

3
我正在尝试使用Qt、C++和LibGit2创建一个简单的用户界面,用于显示git分支。
我已经做了调查,但似乎找不到任何解释如何实现这个过程的内容。
我对C++和git还很新,所以如果您认为这是一个愚蠢的问题,请提前谅解。我只是想学点新东西。
1个回答

4
请参考git_branch_iterator函数。例如:
git_branch_iterator *it;
if (!git_branch_iterator_new(&it, repo, GIT_BRANCH_ALL)) {
  git_reference *ref;
  git_branch_t type;
  while (!git_branch_next(&ref, &type, it)) {
    // Do something with 'ref' and 'type'.
    git_reference_free(ref);
  }
  git_branch_iterator_free(it);
}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接