1 /* Copy from Git cache.h*/
\r
6 //#pragma pack(show)
\r
7 #define CACHE_SIGNATURE 0x44495243 /* "DIRC" */
\r
8 struct cache_header {
\r
9 unsigned int hdr_signature;
\r
10 unsigned int hdr_version;
\r
11 unsigned int hdr_entries;
\r
15 * The "cache_time" is just the low 32 bits of the
\r
16 * time. It doesn't matter if it overflows - we only
\r
17 * check it for equality in the 32 bits we save.
\r
25 * dev/ino/uid/gid/size are also just tracked to the low 32 bits
\r
26 * Again - this is just a (very strong in practice) heuristic that
\r
27 * the inode hasn't changed.
\r
29 * We save the fields in big-endian order to allow using the
\r
30 * index file over NFS transparently.
\r
32 struct ondisk_cache_entry {
\r
33 struct cache_time ctime;
\r
34 struct cache_time mtime;
\r
43 char name[FLEX_ARRAY]; /* more */
\r
47 * This struct is used when CE_EXTENDED bit is 1
\r
48 * The struct must match ondisk_cache_entry exactly from
\r
51 struct ondisk_cache_entry_extended {
\r
52 struct cache_time ctime;
\r
53 struct cache_time mtime;
\r
63 char name[FLEX_ARRAY]; /* more */
\r
68 #define CE_NAMEMASK (0x0fff)
\r
69 #define CE_STAGEMASK (0x3000)
\r
70 #define CE_EXTENDED (0x4000)
\r
71 #define CE_VALID (0x8000)
\r
72 #define CE_STAGESHIFT 12
\r
74 * Range 0xFFFF0000 in ce_flags is divided into
\r
75 * two parts: in-memory flags and on-disk ones.
\r
76 * Flags in CE_EXTENDED_FLAGS will get saved on-disk
\r
77 * if you want to save a new flag, add it in
\r
80 * In-memory only flags
\r
82 #define CE_UPDATE (0x10000)
\r
83 #define CE_REMOVE (0x20000)
\r
84 #define CE_UPTODATE (0x40000)
\r
85 #define CE_ADDED (0x80000)
\r
87 #define CE_HASHED (0x100000)
\r
88 #define CE_UNHASHED (0x200000)
\r
91 * Extended on-disk flags
\r
93 #define CE_INTENT_TO_ADD 0x20000000
\r
94 /* CE_EXTENDED2 is for future extension */
\r
95 #define CE_EXTENDED2 0x80000000
\r
97 #define CE_EXTENDED_FLAGS (CE_INTENT_TO_ADD)
\r
100 * Safeguard to avoid saving wrong flags:
\r
101 * - CE_EXTENDED2 won't get saved until its semantic is known
\r
102 * - Bits in 0x0000FFFF have been saved in ce_flags already
\r
103 * - Bits in 0x003F0000 are currently in-memory flags
\r
105 #if CE_EXTENDED_FLAGS & 0x803FFFFF
\r
106 #error "CE_EXTENDED_FLAGS out of range"
\r
110 * Copy the sha1 and stat state of a cache entry from one to
\r
111 * another. But we never change the name, or the hash state!
\r
113 #define CE_STATE_MASK (CE_HASHED | CE_UNHASHED)
\r
119 BYTE *p1=(BYTE*)&data;
\r
120 BYTE *p2=(BYTE*)&ret;
\r
121 for(int i=0;i<sizeof(T);i++)
\r
123 p2[sizeof(T)-i-1] = p1[i];
\r
129 static inline size_t ce_namelen(T *ce)
\r
131 size_t len = Big2lit(ce->flags) & CE_NAMEMASK;
\r
132 if (len < CE_NAMEMASK)
\r
134 return strlen(ce->name + CE_NAMEMASK) + CE_NAMEMASK;
\r
137 #define flexible_size(STRUCT,len) ((offsetof(STRUCT,name) + (len) + 8) & ~7)
\r
139 //#define ondisk_cache_entry_size(len) flexible_size(ondisk_cache_entry,len)
\r
140 //#define ondisk_cache_entry_extended_size(len) flexible_size(ondisk_cache_entry_extended,len)
\r
142 //#define ondisk_ce_size(ce) (((ce)->flags & CE_EXTENDED) ? \
\r
143 // ondisk_cache_entry_extended_size(ce_namelen(ce)) : \
\r
144 // ondisk_cache_entry_size(ce_namelen(ce)))
\r
147 static inline size_t ondisk_ce_size(T *ce)
\r
149 return flexible_size(T,ce_namelen(ce));
\r
155 CString m_FileName;
\r
156 __time64_t m_ModifyTime;
\r
160 int FillData(ondisk_cache_entry* entry);
\r
161 int FillData(ondisk_cache_entry_extended* entry);
\r
165 typedef void (*FIll_STATUS_CALLBACK)(CString &path,git_wc_status_kind status,void *pdata);
\r
167 class CGitIndexList:public std::vector<CGitIndex>
\r
172 std::map<CString,int> m_Map;
\r
173 __time64_t m_LastModifyTime;
\r
175 int ReadIndex(CString file);
\r
176 int GetStatus(CString &gitdir,CString &path,git_wc_status_kind * status,BOOL IsFull=false, BOOL IsRecursive=false,FIll_STATUS_CALLBACK callback=NULL,void *pData=NULL);
\r
178 int GetFileStatus(CString &gitdir,CString &path, git_wc_status_kind * status,struct __stat64 &buf,FIll_STATUS_CALLBACK callback=NULL,void *pData=NULL);
\r
182 class CGitIndexFileMap:public std::map<CString,CGitIndexList>
\r
185 int GetFileStatus(CString &gitdir,CString &path,git_wc_status_kind * status,BOOL IsFull=false, BOOL IsRecursive=false,FIll_STATUS_CALLBACK callback=NULL,void *pData=NULL);
\r