1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2011 - TortoiseGit
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include "GitStatus.h"
28 typedef std::vector
<CGitHash
> GIT_REV_LIST
;
30 #define LOG_REV_AUTHOR_NAME _T('0')
31 #define LOG_REV_AUTHOR_EMAIL _T('1')
32 #define LOG_REV_AUTHOR_DATE _T('2')
33 #define LOG_REV_COMMIT_NAME _T('3')
34 #define LOG_REV_COMMIT_EMAIL _T('4')
35 #define LOG_REV_COMMIT_DATE _T('5')
36 #define LOG_REV_COMMIT_SUBJECT _T('6')
37 #define LOG_REV_COMMIT_BODY _T('7')
38 #define LOG_REV_COMMIT_HASH _T('8')
39 #define LOG_REV_COMMIT_PARENT _T('9')
40 #define LOG_REV_COMMIT_FILE _T('A')
41 #define LOG_REV_ITEM_BEGIN _T('B')
42 #define LOG_REV_ITEM_END _T('C')
49 typedef int CALL_UPDATE_DIFF_ASYNC(GitRev
*pRev
, void *data
);
54 friend class CLogCache
;
58 CString m_AuthorEmail
;
60 CString m_CommitterName
;
61 CString m_CommitterEmail
;
62 CTime m_CommitterDate
;
66 CTGitPathList m_Files
;
72 CALL_UPDATE_DIFF_ASYNC
*m_CallDiffAsync
;
75 if(!m_IsDiffFiles
&& !m_CommitHash
.IsEmpty())
77 SafeFetchFullInfo(&g_Git
);
78 InterlockedExchange(&m_IsDiffFiles
, TRUE
);
79 if(m_IsDiffFiles
&& m_IsCommitParsed
)
80 InterlockedExchange(&m_IsFull
, TRUE
);
86 int & GetAction(void * data
)
89 if(!m_IsDiffFiles
&& m_CallDiffAsync
)
90 m_CallDiffAsync(this, data
);
96 CTGitPathList
& GetFiles(void * data
)
99 if(!m_IsDiffFiles
&& m_CallDiffAsync
)
100 m_CallDiffAsync(this, data
);
106 // GitRev(GitRev &rev);
107 // GitRev &operator=(GitRev &rev);
110 if(!m_IsCommitParsed
&& m_GitCommit
.m_pGitCommit
)
112 ParserFromCommit(&m_GitCommit
);
113 InterlockedExchange(&m_IsCommitParsed
, TRUE
);
114 git_free_commit(&m_GitCommit
);
115 if(m_IsDiffFiles
&& m_IsCommitParsed
)
116 InterlockedExchange(&m_IsFull
, TRUE
);
122 CString
& GetAuthorName()
128 CString
& GetAuthorEmail()
131 return m_AuthorEmail
;
134 CTime
& GetAuthorDate()
140 CString
& GetCommitterName()
143 return m_CommitterName
;
146 CString
&GetCommitterEmail()
149 return m_CommitterEmail
;
152 CTime
&GetCommitterDate()
155 return m_CommitterDate
;
158 CString
& GetSubject()
173 GIT_COMMIT m_GitCommit
;
177 REV_HEAD
= -1, ///< head revision
178 REV_BASE
= -2, ///< base revision
179 REV_WC
= -3, ///< revision of the working copy
180 REV_UNSPECIFIED
= -4, ///< unspecified revision
183 int CopyFrom(GitRev
&rev
,bool OmitParentAndMark
=false);
185 static CString
GetHead(){return CString(_T("HEAD"));};
186 static CString
GetWorkingCopy(){return CString(GIT_REV_ZERO
);};
190 CGitHash m_CommitHash
;
191 GIT_REV_LIST m_ParentHash
;
198 BOOL
IsBoundary(){return m_Mark
== _T('-');}
201 //int ParserFromLog(BYTE_VECTOR &log,int start=0);
202 CTime
ConverFromString(CString input
);
203 inline int ParentsCount(){return m_ParentHash
.size();}
205 //Show version tree Graphic
206 std::vector
<int> m_Lanes
;
208 volatile LONG m_IsFull
;
209 volatile LONG m_IsUpdateing
;
210 volatile LONG m_IsCommitParsed
;
211 volatile LONG m_IsDiffFiles
;
213 int SafeFetchFullInfo(CGit
*git
);
215 int ParserFromCommit(GIT_COMMIT
*commit
);
216 int ParserParentFromCommit(GIT_COMMIT
*commit
);
219 int GetParentFromHash(CGitHash
&hash
);
220 int GetCommitFromHash(CGitHash
&hash
);
221 int GetCommit(CString Rev
);
223 int SafeGetSimpleList(CGit
*git
);
224 volatile LONG m_IsSimpleListReady
;
225 std::vector
<CString
> m_SimpleFileList
; /* use for find and filter*/
226 /* no rename detect and line num stat infor*/
232 TIME_ZONE_INFORMATION m_TimeZone
;