gitbranch.cpp 734 B

1234567891011121314151617181920212223242526272829
  1. #include "gitbranch.h"
  2. #include <QDebug>
  3. #include <gitrepository.h>
  4. #include <git2.h>
  5. GitBranch::GitBranch(git_reference *ref, GitRepository *parent) : GitReference(ref, parent)
  6. ,m_commit(nullptr)
  7. {
  8. char oid_buf[GIT_OID_HEXSZ+1];
  9. const char* tmpName;
  10. git_branch_name(&tmpName, m_raw);
  11. m_name = tmpName;
  12. git_annotated_commit_from_ref(&m_commit, repository()->raw(), m_raw);
  13. const git_oid* tmpOid = git_annotated_commit_id(m_commit);
  14. memcpy(m_oid, tmpOid, sizeof(m_oid));
  15. git_oid_tostr(oid_buf, GIT_OID_HEXSZ+1,branch_oid);
  16. qDebug() << oid_buf;
  17. // m_branches.insert(out)
  18. }
  19. GitBranch::~GitBranch()
  20. {
  21. if(m_commit != nullptr) {
  22. git_annotated_commit_free(m_commit);
  23. }
  24. }