Browse Source

Fix issue with sha1

Alexey Edelev 8 years ago
parent
commit
99dc07b840
4 changed files with 9 additions and 10 deletions
  1. 4 7
      commitmodel.cpp
  2. 1 1
      gitoid.cpp
  3. 3 2
      gitoid.h
  4. 1 0
      qml/MainView.qml

+ 4 - 7
commitmodel.cpp

@@ -18,15 +18,12 @@ CommitModel* CommitModel::fromBranch(GitBranch* branch)
     git_revwalk_sorting(walk, GIT_SORT_TIME);
 
     git_oid newOid;
-    while(git_revwalk_next(&newOid, walk) == 0)
-    {
+    while(git_revwalk_next(&newOid, walk) == 0) {
         GitOid commitOid(&newOid, branch->repository());
-        if(!tmpModel->m_container.isEmpty()) {
-            qDebug() << "Last:" << tmpModel->m_container.last().data()->sha1();
-        }
         GitCommit *commit = GitCommit::fromOid(commitOid);
-        qDebug() << commit->sha1();
-        tmpModel->add(commit);
+        if(commit != nullptr) {
+            tmpModel->add(commit);
+        }
     }
 
     git_revwalk_free(walk);

+ 1 - 1
gitoid.cpp

@@ -15,7 +15,7 @@ GitOid::GitOid(const GitOid& other) : QObject()
     m_repository = other.m_repository;
 }
 
-const QLatin1String& GitOid::toString() const
+QString GitOid::toString() const
 {
     return m_string;
 }

+ 3 - 2
gitoid.h

@@ -2,6 +2,7 @@
 #define GITOID_H
 
 #include <QObject>
+#include <QString>
 #include <git2/oid.h>
 
 class GitRepository;
@@ -25,7 +26,7 @@ public:
         return m_repository;
     }
 
-    const QLatin1String &toString() const;
+    QString toString() const;
 
     bool isValid() const;
 
@@ -33,7 +34,7 @@ private:
     void updateOid(const git_oid* oid);
 
     git_oid m_oid;
-    QLatin1String m_string;
+    QString m_string;
     GitRepository *m_repository;
 };
 

+ 1 - 0
qml/MainView.qml

@@ -38,6 +38,7 @@ Item {
             height: 100
             Text {
                 anchors.centerIn: parent
+                maximumLineCount: 8
                 text: model.sha1
             }
         }