gitbranch.cpp 708 B

123456789101112131415161718192021222324252627282930
  1. #include "gitbranch.h"
  2. #include <QDebug>
  3. #include <gitrepository.h>
  4. #include <git2.h>
  5. GitBranch::GitBranch(git_reference *ref, git_branch_t type, GitRepository *parent) : GitReference(ref, parent)
  6. ,m_commit(nullptr)
  7. ,m_type(static_cast<BranchType>(type))
  8. {
  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. m_oid = GitOid(git_annotated_commit_id(m_commit), m_repository);
  14. qDebug() << m_oid.toString();
  15. }
  16. GitBranch::~GitBranch()
  17. {
  18. if(m_commit != nullptr) {
  19. git_annotated_commit_free(m_commit);
  20. }
  21. }
  22. GitBranch::BranchType GitBranch::type() const
  23. {
  24. return m_type;
  25. }