Drop logically dead code
[TortoiseGit.git] / src / Git / GitRev.h
blob088bbebd2cf59d9977e7d59f30e54b4006f21f40
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2014 - 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.
20 #pragma once
21 #include "gittype.h"
22 #include "GitStatus.h"
23 #include "AtlTime.h"
24 #include "GitHash.h"
25 #include "GitDll.h"
26 #include "Git.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')
44 class CGit;
45 extern CGit g_Git;
46 class GitRev;
47 class CLogCache;
49 typedef int CALL_UPDATE_DIFF_ASYNC(GitRev *pRev, void *data);
51 class GitRev
53 public:
54 friend class CLogCache;
56 protected:
57 CString m_AuthorName;
58 CString m_AuthorEmail;
59 CTime m_AuthorDate;
60 CString m_CommitterName;
61 CString m_CommitterEmail;
62 CTime m_CommitterDate;
63 CString m_Subject;
64 CString m_Body;
66 CTGitPathList m_Files;
67 int m_Action;
68 int m_RebaseAction;
69 CTGitPathList m_UnRevFiles;
71 public:
72 GitRev(void);
74 CALL_UPDATE_DIFF_ASYNC *m_CallDiffAsync;
75 int CheckAndDiff()
77 if(!m_IsDiffFiles && !m_CommitHash.IsEmpty())
79 SafeFetchFullInfo(&g_Git);
80 InterlockedExchange(&m_IsDiffFiles, TRUE);
81 if(m_IsDiffFiles && m_IsCommitParsed)
82 InterlockedExchange(&m_IsFull, TRUE);
83 return 0;
85 return 1;
88 int & GetAction(void * data)
90 CheckAndParser();
91 if(!m_IsDiffFiles && m_CallDiffAsync)
92 m_CallDiffAsync(this, data);
93 else
94 CheckAndDiff();
95 return m_Action;
98 int & GetRebaseAction()
100 return m_RebaseAction;
103 CTGitPathList & GetFiles(void * data)
105 CheckAndParser();
106 if(data && !m_IsDiffFiles && m_CallDiffAsync)
107 m_CallDiffAsync(this, data);
108 else
109 CheckAndDiff();
110 return m_Files;
113 CTGitPathList & GetUnRevFiles()
115 return m_UnRevFiles;
118 // GitRev(GitRev &rev);
119 // GitRev &operator=(GitRev &rev);
120 int CheckAndParser()
122 if(!m_IsCommitParsed && m_GitCommit.m_pGitCommit)
124 ParserFromCommit(&m_GitCommit);
125 InterlockedExchange(&m_IsCommitParsed, TRUE);
126 git_free_commit(&m_GitCommit);
127 if(m_IsDiffFiles && m_IsCommitParsed)
128 InterlockedExchange(&m_IsFull, TRUE);
129 return 0;
131 return 1;
134 CString & GetAuthorName()
136 CheckAndParser();
137 return m_AuthorName;
140 CString & GetAuthorEmail()
142 CheckAndParser();
143 return m_AuthorEmail;
146 CTime & GetAuthorDate()
148 CheckAndParser();
149 return m_AuthorDate;
152 CString & GetCommitterName()
154 CheckAndParser();
155 return m_CommitterName;
158 CString &GetCommitterEmail()
160 CheckAndParser();
161 return m_CommitterEmail;
164 CTime &GetCommitterDate()
166 CheckAndParser();
167 return m_CommitterDate;
170 CString & GetSubject()
172 CheckAndParser();
173 return m_Subject;
176 CString & GetBody()
178 CheckAndParser();
179 return m_Body;
183 ~GitRev(void);
185 GIT_COMMIT m_GitCommit;
187 enum
189 REV_HEAD = -1, ///< head revision
190 REV_BASE = -2, ///< base revision
191 REV_WC = -3, ///< revision of the working copy
192 REV_UNSPECIFIED = -4, ///< unspecified revision
195 int CopyFrom(GitRev &rev,bool OmitParentAndMark=false);
197 static CString GetHead(){return CString(_T("HEAD"));};
198 static CString GetWorkingCopy(){return CString(GIT_REV_ZERO);};
200 CString m_Notes;
202 CGitHash m_CommitHash;
203 GIT_REV_LIST m_ParentHash;
206 TCHAR m_Mark;
207 CString m_Ref;
208 CString m_RefAction;
210 BOOL IsBoundary(){return m_Mark == _T('-');}
212 void Clear();
213 //int ParserFromLog(BYTE_VECTOR &log,int start=0);
214 CTime ConverFromString(CString input);
215 inline int ParentsCount(){ return (int)m_ParentHash.size(); }
217 //Show version tree Graphic
218 std::vector<int> m_Lanes;
220 volatile LONG m_IsFull;
221 volatile LONG m_IsUpdateing;
222 volatile LONG m_IsCommitParsed;
223 volatile LONG m_IsDiffFiles;
225 int SafeFetchFullInfo(CGit *git);
227 int ParserFromCommit(GIT_COMMIT *commit);
228 int ParserParentFromCommit(GIT_COMMIT *commit);
231 int GetParentFromHash(CGitHash &hash);
232 int GetCommitFromHash(CGitHash &hash);
233 int GetCommit(CString Rev);
235 int SafeGetSimpleList(CGit *git);
236 volatile LONG m_IsSimpleListReady;
237 std::vector<CString> m_SimpleFileList; /* use for find and filter*/
238 /* no rename detect and line num stat infor*/
240 public:
241 void DbgPrint();
242 int AddMergeFiles();
243 private:
244 int GetCommitFromHash_withoutLock(CGitHash &hash);
245 TIME_ZONE_INFORMATION m_TimeZone;