OSDN Git Service

Git log basic work but graph tree is wrong when scroll
authorFrank Li <lznuaa@gmail.com>
Mon, 11 Jan 2010 03:05:31 +0000 (11:05 +0800)
committerFrank Li <lznuaa@gmail.com>
Mon, 11 Jan 2010 03:05:31 +0000 (11:05 +0800)
Signed-off-by: Frank Li <lznuaa@gmail.com>
ext/gitdll/gitdll.c
src/Git/Git.h
src/Git/GitRev.cpp
src/TortoiseProc/GitLogListBase.cpp
src/TortoiseProc/LogDataVector.cpp
src/TortoiseProc/LogDlg.cpp

index 29bba8a..72ca9db 100644 (file)
@@ -450,12 +450,33 @@ int git_get_diff_file(GIT_DIFF diff,GIT_FILE file,int i, char **newname, char **
        if(status)\r
                *status = q->queue[i]->status;\r
 \r
-       if(IsBin)\r
-               *IsBin = p_Rev->diffstat.files[i]->is_binary;\r
-       if(inc)\r
-               *inc = p_Rev->diffstat.files[i]->added;\r
-       if(dec)\r
-               *dec = p_Rev->diffstat.files[i]->deleted;\r
+       if(p_Rev->diffstat.files)\r
+       {\r
+               int j;\r
+               for(j=0;j<p_Rev->diffstat.nr;j++)\r
+               {\r
+                       if(strcmp(*newname,p_Rev->diffstat.files[j]->name)==0)\r
+                               break;\r
+               }\r
+               if( j== p_Rev->diffstat.nr)\r
+               {\r
+                       *IsBin=1;\r
+                       *inc=0;\r
+                       *dec=0;\r
+                       return 0;\r
+               }\r
+               if(IsBin)\r
+                       *IsBin = p_Rev->diffstat.files[j]->is_binary;\r
+               if(inc)\r
+                       *inc = p_Rev->diffstat.files[j]->added;\r
+               if(dec)\r
+                       *dec = p_Rev->diffstat.files[j]->deleted;\r
+       }else\r
+       {\r
+               *IsBin=1;\r
+               *inc=0;\r
+               *dec=0;\r
+       }\r
 \r
        return 0;\r
 }
\ No newline at end of file
index 2f2f659..a868e24 100644 (file)
@@ -49,7 +49,10 @@ public:
                if(m_GitDiff)\r
                        return m_GitDiff;\r
                else\r
-                       git_open_diff(&m_GitDiff,"-C -M");\r
+               {\r
+                       git_open_diff(&m_GitDiff,"-C -M -r");\r
+                       return m_GitDiff;\r
+               }\r
        }\r
 \r
        static BOOL CheckMsysGitDir();\r
index b787a68..e23067d 100644 (file)
@@ -272,6 +272,7 @@ int GitRev::SafeFetchFullInfo(CGit *git)
                InterlockedExchange(&m_IsFull,TRUE);\r
                return 0;\r
 #endif\r
+               this->m_Files.Clear();\r
                git->CheckAndInitDll();\r
                GIT_COMMIT commit;\r
                GIT_COMMIT_LIST list;\r
@@ -281,7 +282,7 @@ int GitRev::SafeFetchFullInfo(CGit *git)
 \r
                int i=0;\r
                git_get_commit_first_parent(&commit,&list);\r
-               while(git_get_commit_next_parent(&list,parent))\r
+               while(git_get_commit_next_parent(&list,parent) == 0)\r
                {\r
                        GIT_FILE file;\r
                        int count;\r
@@ -321,6 +322,7 @@ int GitRev::SafeFetchFullInfo(CGit *git)
                                        path.m_StatAdd.Format(_T("%d"),inc);\r
                                        path.m_StatDel.Format(_T("%d"),dec);\r
                                }\r
+                               m_Files.AddPath(path);\r
                        }\r
                        git_diff_flush(git->GetGitDiff());\r
                        i++;\r
@@ -340,7 +342,7 @@ int GitRev::ParserParentFromCommit(GIT_COMMIT *commit)
        GIT_HASH   parent;\r
        \r
        git_get_commit_first_parent(commit,&list);\r
-       while(git_get_commit_next_parent(&list,parent))\r
+       while(git_get_commit_next_parent(&list,parent)==0)\r
        {\r
                m_ParentHash.push_back(CGitHash((char *)parent));\r
        }\r
index 1c55845..58754c7 100644 (file)
@@ -1770,7 +1770,6 @@ int CGitLogListBase::BeginFetchLog()
        {\r
                this->m_logEntries.insert(m_logEntries.begin(),this->m_wcRev.m_CommitHash);\r
                this->m_LogCache.m_HashMap[m_wcRev.m_CommitHash]=m_wcRev;\r
-               m_arShownList.Add(&m_wcRev);\r
        }\r
 \r
        CString cmd=g_Git.GetLogCmd(m_StartRef,path,-1,mask,NULL,NULL,true);\r
@@ -1868,6 +1867,9 @@ void CGitLogListBase::GetTimeRange(CTime &oldest, CTime &latest)
        latest=CTime(1971,1,2,0,0,0);\r
        for(unsigned int i=0;i<m_logEntries.size();i++)\r
        {\r
+               if(m_logEntries[i].IsEmpty())\r
+                       continue;\r
+\r
                if(m_logEntries.GetGitRevAt(i).m_AuthorDate.GetTime() < oldest.GetTime())\r
                        oldest = m_logEntries.GetGitRevAt(i).m_AuthorDate.GetTime();\r
 \r
@@ -2060,6 +2062,9 @@ UINT CGitLogListBase::LogThread()
        if( m_logEntries.size() > 0)\r
        {\r
                GitRev *pRev = &m_logEntries.GetGitRevAt(0);\r
+               \r
+               m_arShownList.Add(pRev);\r
+\r
                if( pRev->m_CommitHash.IsEmpty() )\r
                {\r
                        pRev->m_Files.Clear();\r
@@ -2076,6 +2081,8 @@ UINT CGitLogListBase::LogThread()
                }\r
        }\r
 \r
+       InterlockedExchange(&m_bNoDispUpdates, FALSE);\r
+\r
        git_get_log_firstcommit(m_DllGitLog);\r
        GIT_COMMIT commit;\r
        t1=GetTickCount();\r
@@ -2107,18 +2114,20 @@ UINT CGitLogListBase::LogThread()
                        pRev->ParserParentFromCommit(&commit);\r
                }\r
 \r
+               m_arShownList.Add(pRev);\r
+\r
                if(t2-t1>500 && m_logEntries.size()<(oldsize+100) )\r
                {\r
                        //update UI\r
                        oldsize = m_logEntries.size();\r
-                       //PostMessage(LVM_SETITEMCOUNT, (WPARAM) this->m_logEntries.size(),(LPARAM) LVSICF_NOINVALIDATEALL);\r
-                       //::PostMessage(this->GetParent()->m_hWnd,MSG_LOAD_PERCENTAGE,(WPARAM) GITLOG_END,0);\r
+                       PostMessage(LVM_SETITEMCOUNT, (WPARAM) this->m_logEntries.size(),(LPARAM) LVSICF_NOINVALIDATEALL);\r
+                       ::PostMessage(this->GetParent()->m_hWnd,MSG_LOAD_PERCENTAGE,(WPARAM) GITLOG_END,0);\r
                }               \r
        }\r
        \r
        //Update UI;\r
-       //PostMessage(LVM_SETITEMCOUNT, (WPARAM) this->m_logEntries.size(),(LPARAM) LVSICF_NOINVALIDATEALL);\r
-       //::PostMessage(this->GetParent()->m_hWnd,MSG_LOAD_PERCENTAGE,(WPARAM) GITLOG_END,0);\r
+       PostMessage(LVM_SETITEMCOUNT, (WPARAM) this->m_logEntries.size(),(LPARAM) LVSICF_NOINVALIDATEALL);\r
+       ::PostMessage(this->GetParent()->m_hWnd,MSG_LOAD_PERCENTAGE,(WPARAM) GITLOG_END,0);\r
 \r
        InterlockedExchange(&m_bThreadRunning, FALSE);\r
 \r
index bea1486..0c6d3d4 100644 (file)
@@ -311,7 +311,7 @@ void CLogDataVector::updateLanes(GitRev& c, Lanes& lns, CGitHash &sha)
                lns.changeActiveLane(sha); // uses previous isBoundary state\r
 \r
        lns.setBoundary(c.IsBoundary() == TRUE); // update must be here\r
-       TRACE(_T("%s %d"),c.m_CommitHash,c.IsBoundary());\r
+       TRACE(_T("%s %d"),c.m_CommitHash.ToString(),c.IsBoundary());\r
 \r
        if (isFork)\r
                lns.setFork(sha);\r
index 7bd38c3..91404f5 100644 (file)
@@ -372,6 +372,12 @@ LRESULT CLogDlg::OnLogListLoading(WPARAM wParam, LPARAM /*lParam*/)
        }else if( cur == GITLOG_END)\r
        {\r
                \r
+               if(this->m_LogList.HasText())\r
+               {\r
+                       this->m_LogList.ClearText();\r
+                       UpdateLogInfoLabel();\r
+               }\r
+\r
                //if (!m_bShowedAll)\r
                DialogEnableWindow(IDC_SHOWWHOLEPROJECT, TRUE);\r
 \r