1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2013, 2015-2017 - 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.
21 #include "GitRevLoglist.h"
24 #define LOG_INDEX_MAGIC 0x88AA5566
25 #define LOG_DATA_MAGIC 0x99BB0FFF
26 #define LOG_DATA_ITEM_MAGIC 0x0FCC9ACC
27 #define LOG_DATA_FILE_MAGIC 0x19EE9DFF
28 #define LOG_INDEX_VERSION 0x11
31 struct SLogCacheIndexHeader
38 struct SLogCacheIndexItem
44 struct SLogCacheIndexFile
46 struct SLogCacheIndexHeader m_Header
;
47 struct SLogCacheIndexItem m_Item
[1]; //dynmatic size
50 struct SLogCacheRevFileHeader
60 DWORD m_OldFileNameSize
;
64 struct SLogCacheRevItemHeader
70 struct SLogCacheDataFileHeader
77 class CGitHashMap
: public std::unordered_map
<CGitHash
, GitRevLoglist
>
80 bool IsExist(CGitHash
&hash
)
82 return find(hash
) != end();
86 #define INDEX_FILE_NAME L"tortoisegit.index"
87 #define DATA_FILE_NAME L"tortoisegit.data"
97 HANDLE m_IndexFileMap
;
98 SLogCacheIndexFile
*m_pCacheIndex
;
103 HANDLE m_DataFileMap
;
105 DWORD m_DataFileLength
;
107 void CloseDataHandles();
108 void CloseIndexHandles();
110 BOOL
CheckHeader(SLogCacheIndexHeader
*header
)
112 if (header
->m_Magic
!= LOG_INDEX_MAGIC
)
115 if (header
->m_Version
!= LOG_INDEX_VERSION
)
121 BOOL
CheckHeader(SLogCacheRevFileHeader
*header
)
123 if (header
->m_Magic
!= LOG_DATA_FILE_MAGIC
)
129 BOOL
CheckHeader(SLogCacheRevItemHeader
*header
)
131 if (header
->m_Magic
!= LOG_DATA_ITEM_MAGIC
)
137 BOOL
CheckHeader(SLogCacheDataFileHeader
*header
)
139 if (header
->m_Magic
!= LOG_DATA_MAGIC
)
142 if (header
->m_Version
!= LOG_INDEX_VERSION
)
148 int SaveOneItem(const GitRevLoglist
& Rev
, LONG offset
);
151 int RebuildCacheFile();
156 int FetchCacheIndex(CString GitDir
);
157 int LoadOneItem(GitRevLoglist
& Rev
, ULONGLONG offset
);
158 ULONGLONG
GetOffset(const CGitHash
& hash
, SLogCacheIndexFile
* pData
= nullptr);
160 CGitHashMap m_HashMap
;
162 GitRevLoglist
* GetCacheData(const CGitHash
& hash
);
165 int ClearAllParent();
166 void ClearAllLanes();