OSDN Git Service

Share resource file between TortoiseGitBlame and TortoiseProc
[tortoisegit/TortoiseGitJp.git] / src / Git / GitRev.cpp
index dc08239..bc9aee3 100644 (file)
@@ -1,10 +1,12 @@
 #include "StdAfx.h"\r
 #include "GitRev.h"\r
-\r
+#include "Git.h"\r
 \r
 GitRev::GitRev(void)\r
 {\r
        m_Action=0;\r
+       m_IsFull = 0;\r
+       m_IsUpdateing = 0;\r
 }\r
 \r
 GitRev::~GitRev(void)\r
@@ -31,8 +33,26 @@ void GitRev::Clear()
        m_Body.Empty();\r
        m_Subject.Empty();\r
        m_CommitHash.Empty();\r
+       m_Mark=0;\r
 \r
 }\r
+int GitRev::CopyFrom(GitRev &rev)\r
+{\r
+       m_AuthorName    =rev.m_AuthorName       ;\r
+       m_AuthorEmail   =rev.m_AuthorEmail      ;\r
+       m_AuthorDate    =rev.m_AuthorDate       ;\r
+       m_CommitterName =rev.m_CommitterName    ;\r
+       m_CommitterEmail=rev.m_CommitterEmail;\r
+       m_CommitterDate =rev.m_CommitterDate    ;\r
+       m_Subject               =rev.m_Subject          ;\r
+       m_Body                  =rev.m_Body                     ;\r
+       m_CommitHash    =rev.m_CommitHash       ;\r
+       m_ParentHash    =rev.m_ParentHash       ;\r
+       m_Files                 =rev.m_Files                    ;       \r
+       m_Action                =rev.m_Action           ;\r
+       m_Mark                  =rev.m_Mark;\r
+       return 0;\r
+}\r
 int GitRev::ParserFromLog(CString &log)\r
 {\r
        int pos=0;\r
@@ -40,7 +60,7 @@ int GitRev::ParserFromLog(CString &log)
        CString key;\r
        CString text;\r
        CString filelist;\r
-       TCHAR mode;\r
+       TCHAR mode=0;\r
        CTGitPath  path;\r
        this->m_Files.Clear();\r
     m_Action=0;\r
@@ -82,10 +102,21 @@ int GitRev::ParserFromLog(CString &log)
                                this->m_Body = text +_T("\n");\r
                                break;\r
                        case LOG_REV_COMMIT_HASH:\r
-                               this->m_CommitHash = text;\r
+                               this->m_CommitHash = text.Right(40);\r
+                               if(text.GetLength()>40)\r
+                               {\r
+                                       this->m_Mark=text[0];\r
+                               }\r
                                break;\r
                        case LOG_REV_COMMIT_PARENT:\r
-                               this->m_ParentHash.insert(this->m_ParentHash.end(),text);\r
+                               while(text.GetLength()>0)\r
+                               {\r
+                                       this->m_ParentHash.insert(this->m_ParentHash.end(),text.Left(40));\r
+                                       if(text.GetLength()>40)\r
+                                               text=text.Right(text.GetLength()-41);\r
+                                       else\r
+                                               break;\r
+                               }\r
                                break;\r
                        case LOG_REV_COMMIT_FILE:\r
                                break;\r
@@ -120,3 +151,27 @@ CTime GitRev::ConverFromString(CString input)
                         _wtoi(input.Mid(20,4)));\r
        return tm;\r
 }\r
+\r
+int GitRev::SafeFetchFullInfo(CGit *git)\r
+{\r
+       if(InterlockedExchange(&m_IsUpdateing,TRUE) == FALSE)\r
+       {\r
+               //GitRev rev;\r
+               CString onelog;\r
+               TCHAR oldmark=this->m_Mark;\r
+       \r
+               git->GetLog(onelog,m_CommitHash,NULL,1);\r
+               CString oldhash=m_CommitHash;\r
+               ParserFromLog(onelog);\r
+               \r
+               //ASSERT(oldhash==m_CommitHash);\r
+               if(oldmark!=0)\r
+                       this->m_Mark=oldmark;  //parser full log will cause old mark overwrited. \r
+                                                              //So we need keep old bound mark.\r
+\r
+               InterlockedExchange(&m_IsUpdateing,FALSE);\r
+               InterlockedExchange(&m_IsFull,TRUE);\r
+               return 0;\r
+       }\r
+       return -1;\r
+}
\ No newline at end of file