Use correct length for buffer
[TortoiseGit.git] / src / TortoiseProc / LogDlgHelper.h
blob9233d452c4f34a9c3f13efabb397854dda0973fa
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2007 - TortoiseSVN
4 // Copyright (C) 2008-2016 - TortoiseGit
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software Foundation,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #pragma once
21 #include "lanes.h"
22 #include "GitHash.h"
23 #include "GitLogCache.h"
24 class CLogDlg;
26 /**
27 * \ingroup TortoiseProc
28 * Instances of CStoreSelection save the selection of the CLogDlg. When the instance
29 * is deleted the destructor restores the selection.
31 typedef std::map<CGitHash, int> MAP_HASH_REV;
33 /**
34 * \ingroup TortoiseProc
35 * Helper class for the log dialog, handles all the log entries, including
36 * sorting.
38 class CLogDataVector : public std::vector<CGitHash>
40 public:
41 CLogCache *m_pLogCache;
42 /// De-allocates log items.
43 CLogDataVector(CLogCache *pLogCache)
45 m_pLogCache=pLogCache;
46 m_FirstFreeLane=0;
47 // Default to value set in Registry
48 m_logOrderBy = CRegDWORD(L"Software\\TortoiseGit\\LogOrderBy", CGit::LOG_ORDER_TOPOORDER);
50 CLogDataVector()
52 m_pLogCache = nullptr;
53 m_FirstFreeLane=0;
54 // Default to value set in Registry
55 m_logOrderBy = CRegDWORD(L"Software\\TortoiseGit\\LogOrderBy", CGit::LOG_ORDER_TOPOORDER);
57 void SetLogCache(CLogCache *pLogCache)
59 m_pLogCache = pLogCache;
61 GitRevLoglist& GetGitRevAt(size_t i)
63 ASSERT(i<size());
64 return m_pLogCache->m_HashMap[(*this)[i]];
66 void ClearAll();
67 int ParserFromLog(CTGitPath* path = nullptr, DWORD count = 0, DWORD infomask = CGit::LOG_INFO_STAT | CGit::LOG_INFO_FILESTATE | CGit::LOG_INFO_SHOW_MERGEDFILE, CString* range = nullptr);
68 int Fill(std::set<CGitHash>& hashes);
70 int FetchFullInfo(int i);
72 Lanes m_Lns;
73 int m_FirstFreeLane;
74 // Log order: LOG_ORDER_CHRONOLOGIALREVERSED, LOG_ORDER_TOPOORDER, LOG_ORDER_DATEORDER
75 int m_logOrderBy;
76 MAP_HASH_REV m_HashMap;
77 void updateLanes(GitRevLoglist& c, Lanes& lns, CGitHash& sha);
78 void setLane(CGitHash& sha) ;
79 void append(CGitHash& sha, bool storeInVector);
81 #if 0
82 /// Ascending date sorting.
83 struct AscDateSort
85 bool operator()(GitRev& pStart, GitRev& pEnd)
87 return pStart->tmDate < pEnd->tmDate;
90 /// Descending date sorting.
91 struct DescDateSort
93 bool operator()(GitRev& pStart, GitRev& pEnd)
95 return pStart->tmDate > pEnd->tmDate;
98 /// Ascending revision sorting.
99 struct AscRevSort
101 bool operator()(GitRev& pStart, GitRev& pEnd)
103 return pStart->Rev < pEnd->Rev;
106 /// Descending revision sorting.
107 struct DescRevSort
109 bool operator()(GitRev& pStart, GitRev& pEnd)
111 return pStart->Rev > pEnd->Rev;
114 /// Ascending author sorting.
115 struct AscAuthorSort
117 bool operator()(GitRev& pStart, GitRev& pEnd)
119 int ret = pStart->sAuthor.CompareNoCase(pEnd->sAuthor);
120 if (ret == 0)
121 return pStart->Rev < pEnd->Rev;
122 return ret<0;
125 /// Descending author sorting.
126 struct DescAuthorSort
128 bool operator()(GitRev& pStart, GitRev& pEnd)
130 int ret = pStart->sAuthor.CompareNoCase(pEnd->sAuthor);
131 if (ret == 0)
132 return pStart->Rev > pEnd->Rev;
133 return ret>0;
136 /// Ascending bugID sorting.
137 struct AscBugIDSort
139 bool operator()(GitRev& pStart, GitRev& pEnd)
141 int ret = pStart->sBugIDs.CompareNoCase(pEnd->sBugIDs);
142 if (ret == 0)
143 return pStart->Rev < pEnd->Rev;
144 return ret<0;
147 /// Descending bugID sorting.
148 struct DescBugIDSort
150 bool operator()(GitRev& pStart, GitRev& pEnd)
152 int ret = pStart->sBugIDs.CompareNoCase(pEnd->sBugIDs);
153 if (ret == 0)
154 return pStart->Rev > pEnd->Rev;
155 return ret>0;
158 /// Ascending message sorting.
159 struct AscMessageSort
161 bool operator()(GitRev& pStart, GitRev& pEnd)
163 return pStart->sShortMessage.CompareNoCase(pEnd->sShortMessage)<0;
166 /// Descending message sorting.
167 struct DescMessageSort
169 bool operator()(GitRev& pStart, GitRev& pEnd)
171 return pStart->sShortMessage.CompareNoCase(pEnd->sShortMessage)>0;
174 /// Ascending action sorting
175 struct AscActionSort
177 bool operator() (GitRev& pStart, GitRev& pEnd)
179 if (pStart->actions == pEnd->actions)
180 return pStart->Rev < pEnd->Rev;
181 return pStart->actions < pEnd->actions;
184 /// Descending action sorting
185 struct DescActionSort
187 bool operator() (GitRev& pStart, GitRev& pEnd)
189 if (pStart->actions == pEnd->actions)
190 return pStart->Rev > pEnd->Rev;
191 return pStart->actions > pEnd->actions;
194 #endif