1
// TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2020 - 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.
31 typedef void CALL_UPDATE_DIFF_ASYNC(GitRevLoglist
* pRev
, IAsyncDiffCB
* data
);
33 class GitRevLoglist
: public GitRev
36 friend class CLogCache
;
41 class GitRevLoglistSharedFiles
44 GitRevLoglistSharedFiles(PSRWLOCK lock
, const CTGitPathList
& files
)
48 AcquireSRWLockShared(m_lock
);
51 ~GitRevLoglistSharedFiles() { ReleaseSRWLockShared(m_lock
); }
53 inline int GetCount() const { return m_files
.GetCount(); }
54 inline const CTGitPath
& operator[](INT_PTR index
) const { return m_files
[index
]; }
56 const CTGitPathList
& m_files
;
62 class GitRevLoglistSharedFilesWriter
65 GitRevLoglistSharedFilesWriter(PSRWLOCK lock
, CTGitPathList
& files
, CTGitPathList
& unrevfiles
)
68 , m_UnRevFiles(unrevfiles
)
70 AcquireSRWLockExclusive(m_lock
);
73 ~GitRevLoglistSharedFilesWriter() { ReleaseSRWLockExclusive(m_lock
); }
75 CTGitPathList
& m_files
;
76 CTGitPathList
& m_UnRevFiles
;
84 unsigned int m_Action
;
85 CTGitPathList m_Files
;
86 CTGitPathList m_UnRevFiles
;
94 CString m_Ref
; // for Refloglist
95 CString m_RefAction
; // for Refloglist
97 // Show version tree Graphic
98 std::vector
<int> m_Lanes
;
100 static std::shared_ptr
<CGitMailmap
> s_Mailmap
;
102 volatile LONG m_IsDiffFiles
;
104 CALL_UPDATE_DIFF_ASYNC
*m_CallDiffAsync
;
108 if (!m_IsDiffFiles
&& !m_CommitHash
.IsEmpty())
111 ret
= SafeFetchFullInfo(&g_Git
);
112 InterlockedExchange(&m_IsDiffFiles
, TRUE
);
119 unsigned int& GetAction(IAsyncDiffCB
* data
)
121 if (!m_IsDiffFiles
&& m_CallDiffAsync
)
122 m_CallDiffAsync(this, data
);
128 int& GetRebaseAction()
130 return m_RebaseAction
;
133 GitRevLoglistSharedFiles
GetFiles(IAsyncDiffCB
* data
)
135 // data might be nullptr when instant data is requested, cf. CGitLogListAction
136 if (data
&& !m_IsDiffFiles
&& m_CallDiffAsync
)
137 m_CallDiffAsync(this, data
);
140 return GitRevLoglistSharedFiles(&m_lock
, m_Files
);
143 GitRevLoglistSharedFilesWriter
GetFilesWriter()
145 return GitRevLoglistSharedFilesWriter(&m_lock
, m_Files
, m_UnRevFiles
);
148 CTGitPathList
& GetUnRevFiles()
153 void Parse(GIT_COMMIT
* commit
, const CGitMailmap
* mailmap
)
155 ParserParentFromCommit(commit
);
156 ParserFromCommit(commit
);
157 // no caching here, because mailmap might have changed
159 ApplyMailmap(*mailmap
);
163 CString
& GetAuthorName()
168 CString
& GetAuthorEmail()
170 return m_AuthorEmail
;
173 CTime
& GetAuthorDate()
178 CString
& GetCommitterName()
180 return m_CommitterName
;
183 CString
& GetCommitterEmail()
185 return m_CommitterEmail
;
188 CTime
& GetCommitterDate()
190 return m_CommitterDate
;
193 CString
& GetSubject()
203 CString
GetSubjectBody(bool crlf
= false) const
205 CString
ret(m_Subject
);
215 CString
body(m_Body
);
216 body
.Replace(L
"\n", L
"\r\n");
217 ret
+= body
.TrimRight();
222 BOOL
IsBoundary() const { return m_Mark
== L
'-'; }
224 virtual void Clear() override
;
226 int SafeFetchFullInfo(CGit
* git
);
228 int SafeGetSimpleList(CGit
* git
);
229 volatile LONG m_IsSimpleListReady
;
230 STRING_VECTOR m_SimpleFileList
; /* use for find and filter, no rename detection and line num stat info */
232 static int GetRefLog(const CString
& ref
, std::vector
<GitRevLoglist
>& refloglist
, CString
& error
);