Make sure we also kill AsyncReadStdErrThread when we kill a thread
[TortoiseGit.git] / src / Git / GitRevLoglist.h
blob345d8d625ca78201c208cc328e74de354f88611d
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2016 - 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 "GitRev.h"
23 class CGit;
24 extern CGit g_Git;
25 class GitRevLoglist;
26 class CLogCache;
28 typedef int CALL_UPDATE_DIFF_ASYNC(GitRevLoglist* pRev, void* data);
30 class GitRevLoglist : public GitRev
32 public:
33 friend class CLogCache;
35 GitRevLoglist(void);
36 ~GitRevLoglist(void);
38 protected:
39 int m_RebaseAction;
40 int m_Action;
41 CTGitPathList m_Files;
42 CTGitPathList m_UnRevFiles;
44 public:
45 GIT_COMMIT m_GitCommit;
47 CString m_Notes;
49 TCHAR m_Mark;
50 CString m_Ref; // for Refloglist
51 CString m_RefAction; // for Refloglist
53 // Show version tree Graphic
54 std::vector<int> m_Lanes;
56 volatile LONG m_IsFull;
57 volatile LONG m_IsUpdateing;
58 volatile LONG m_IsCommitParsed;
59 volatile LONG m_IsDiffFiles;
61 CALL_UPDATE_DIFF_ASYNC *m_CallDiffAsync;
63 int CheckAndDiff()
65 if (!m_IsDiffFiles && !m_CommitHash.IsEmpty())
67 int ret = 0;
68 ret = SafeFetchFullInfo(&g_Git);
69 InterlockedExchange(&m_IsDiffFiles, TRUE);
70 if (m_IsCommitParsed)
71 InterlockedExchange(&m_IsFull, TRUE);
72 return ret;
74 return 1;
77 public:
78 int& GetAction(void* data)
80 CheckAndParser();
81 if (!m_IsDiffFiles && m_CallDiffAsync)
82 m_CallDiffAsync(this, data);
83 else
84 CheckAndDiff();
85 return m_Action;
88 int& GetRebaseAction()
90 return m_RebaseAction;
93 CTGitPathList& GetFiles(void* data)
95 CheckAndParser();
96 if (data && !m_IsDiffFiles && m_CallDiffAsync)
97 m_CallDiffAsync(this, data);
98 else
99 CheckAndDiff();
100 return m_Files;
103 CTGitPathList& GetUnRevFiles()
105 return m_UnRevFiles;
108 protected:
109 void CheckAndParser()
111 if (!m_IsCommitParsed && m_GitCommit.m_pGitCommit)
113 ParserFromCommit(&m_GitCommit);
114 InterlockedExchange(&m_IsCommitParsed, TRUE);
115 git_free_commit(&m_GitCommit);
116 if (m_IsDiffFiles)
117 InterlockedExchange(&m_IsFull, TRUE);
121 public:
122 CString& GetAuthorName()
124 CheckAndParser();
125 return m_AuthorName;
128 CString& GetAuthorEmail()
130 CheckAndParser();
131 return m_AuthorEmail;
134 CTime& GetAuthorDate()
136 CheckAndParser();
137 return m_AuthorDate;
140 CString& GetCommitterName()
142 CheckAndParser();
143 return m_CommitterName;
146 CString& GetCommitterEmail()
148 CheckAndParser();
149 return m_CommitterEmail;
152 CTime& GetCommitterDate()
154 CheckAndParser();
155 return m_CommitterDate;
158 CString& GetSubject()
160 CheckAndParser();
161 return m_Subject;
164 CString& GetBody()
166 CheckAndParser();
167 return m_Body;
170 CString GetSubjectBody(bool crlf = false)
172 CheckAndParser();
173 CString ret(m_Subject);
174 if (!crlf)
176 ret += _T("\n\n");
177 ret += m_Body;
179 else
181 ret.TrimRight();
182 ret += _T("\r\n\r\n");
183 CString body(m_Body);
184 body.Replace(_T("\n"), _T("\r\n"));
185 ret += body.TrimRight();
187 return ret;
190 BOOL IsBoundary() { return m_Mark == _T('-'); }
192 virtual void Clear();
194 int SafeFetchFullInfo(CGit* git);
196 int SafeGetSimpleList(CGit* git);
197 volatile LONG m_IsSimpleListReady;
198 STRING_VECTOR m_SimpleFileList; /* use for find and filter, no rename detection and line num stat info */
200 static int GetRefLog(const CString& ref, std::vector<GitRevLoglist>& refloglist, CString& error);