1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2013, 2015-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.
23 #include "GitRevLoglist.h"
26 #define LOG_INDEX_MAGIC 0x88AA5566
27 #define LOG_DATA_MAGIC 0x99BB0FFF
28 #define LOG_DATA_ITEM_MAGIC 0x0FCC9ACC
29 #define LOG_DATA_FILE_MAGIC 0x19EE9DFF
30 #define LOG_INDEX_VERSION 0x10
33 struct SLogCacheIndexHeader
40 struct SLogCacheIndexItem
46 struct SLogCacheIndexFile
48 struct SLogCacheIndexHeader m_Header
;
49 struct SLogCacheIndexItem m_Item
[1]; //dynmatic size
52 struct SLogCacheRevFileHeader
63 DWORD m_OldFileNameSize
;
68 struct SLogCacheRevItemHeader
75 struct SLogCacheDataFileHeader
81 class CGitHashMap
: public std::unordered_map
<CGitHash
, GitRevLoglist
>
84 bool IsExist(CGitHash
&hash
)
86 return find(hash
) != end();
90 #define INDEX_FILE_NAME L"tortoisegit.index"
91 #define DATA_FILE_NAME L"tortoisegit.data"
101 HANDLE m_IndexFileMap
;
102 SLogCacheIndexFile
*m_pCacheIndex
;
107 HANDLE m_DataFileMap
;
109 DWORD m_DataFileLength
;
111 void CloseDataHandles();
112 void CloseIndexHandles();
115 BOOL
CheckHeader(SLogCacheIndexHeader
*header
)
117 if (header
->m_Magic
!= LOG_INDEX_MAGIC
)
120 if (header
->m_Version
!= LOG_INDEX_VERSION
)
126 BOOL
CheckHeader(SLogCacheRevFileHeader
*header
)
128 if (header
->m_Magic
!= LOG_DATA_FILE_MAGIC
)
131 if (header
->m_Version
!= LOG_INDEX_VERSION
)
137 BOOL
CheckHeader(SLogCacheRevItemHeader
*header
)
139 if (header
->m_Magic
!= LOG_DATA_ITEM_MAGIC
)
142 if (header
->m_Version
!= LOG_INDEX_VERSION
)
148 BOOL
CheckHeader(SLogCacheDataFileHeader
*header
)
150 if (header
->m_Magic
!= LOG_DATA_MAGIC
)
153 if (header
->m_Version
!= LOG_INDEX_VERSION
)
159 int SaveOneItem(const GitRevLoglist
& Rev
, LONG offset
);
162 int RebuildCacheFile();
167 int FetchCacheIndex(CString GitDir
);
168 int LoadOneItem(GitRevLoglist
& Rev
, ULONGLONG offset
);
169 ULONGLONG
GetOffset(const CGitHash
& hash
, SLogCacheIndexFile
* pData
= nullptr);
171 CGitHashMap m_HashMap
;
173 GitRevLoglist
* GetCacheData(const CGitHash
& hash
);
176 int ClearAllParent();
177 void ClearAllLanes();