1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2013 - 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.
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 0xF
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
62 DWORD m_OldFileNameSize
;
67 struct SLogCacheRevItemHeader
74 struct SLogCacheDataFileHeader
80 class CGitHashMap
:public std::map
<CGitHash
,GitRev
>
83 bool IsExist(CGitHash
&hash
)
85 return find(hash
) != end();
89 #define INDEX_FILE_NAME _T("tortoisegit.index")
90 #define DATA_FILE_NAME _T("tortoisegit.data")
91 #define LOCK_FILE_NAME _T("tortoisegit.lock")
102 HANDLE m_IndexFileMap
;
103 SLogCacheIndexFile
*m_pCacheIndex
;
108 HANDLE m_DataFileMap
;
110 DWORD m_DataFileLength
;
112 void CloseDataHandles();
113 void CloseIndexHandles();
116 BOOL
CheckHeader(SLogCacheIndexHeader
*header
)
118 if (header
->m_Magic
!= LOG_INDEX_MAGIC
)
121 if (header
->m_Version
!= LOG_INDEX_VERSION
)
127 BOOL
CheckHeader(SLogCacheRevFileHeader
*header
)
129 if (header
->m_Magic
!= LOG_DATA_FILE_MAGIC
)
132 if (header
->m_Version
!= LOG_INDEX_VERSION
)
138 BOOL
CheckHeader(SLogCacheRevItemHeader
*header
)
140 if (header
->m_Magic
!= LOG_DATA_ITEM_MAGIC
)
143 if (header
->m_Version
!= LOG_INDEX_VERSION
)
149 BOOL
CheckHeader(SLogCacheDataFileHeader
*header
)
151 if (header
->m_Magic
!= LOG_DATA_MAGIC
)
154 if (header
->m_Version
!= LOG_INDEX_VERSION
)
160 int SaveOneItem(GitRev
&Rev
, LONG offset
);
163 int RebuildCacheFile();
168 int FetchCacheIndex(CString GitDir
);
169 int LoadOneItem(GitRev
&Rev
,ULONGLONG offset
);
170 ULONGLONG
GetOffset(CGitHash
&hash
, SLogCacheIndexFile
*pData
=NULL
);
172 CGitHashMap m_HashMap
;
174 GitRev
* GetCacheData(CGitHash
&hash
);
175 int AddCacheEntry(GitRev
&Rev
);
178 int ClearAllParent();
179 void ClearAllLanes();